当前位置: 首页 > news >正文

浙江金圣建设有限公司网站宜兴网站建设

浙江金圣建设有限公司网站,宜兴网站建设,郑州营销型网站推广工具,wordpress 后台很慢一、概念 类似于 ViewPager,1.4 版本之前需要借助 accompanis 库,底层基于 LazyColumn、LazyRow 实现,在使用上也基本相同。默认情况下 HorizontalPager 占据屏幕的整个宽度,VerticalPager 会占据整个高度。 fun HorizontalPager(…

一、概念

类似于 ViewPager,1.4 版本之前需要借助 accompanis 库,底层基于 LazyColumn、LazyRow 实现,在使用上也基本相同。默认情况下 HorizontalPager 占据屏幕的整个宽度,VerticalPager 会占据整个高度。

fun HorizontalPager(pageCount: Int,    //页面数量modifier: Modifier = Modifier,state: PagerState = rememberPagerState(),    //控制监听页面状态的对象contentPadding: PaddingValues = PaddingValues(0.dp),    //内容内边距pageSize: PageSize = PageSize.Fill,    //页面填充模式(填充满Fill,自适应Fixed)beyondBoundsPageCount: Int = 0,    //当前页面前后预加载的页面数量pageSpacing: Dp = 0.dp,    //两个页面之间的间隙verticalAlignment: Alignment.Vertical = Alignment.CenterVertically,flingBehavior: SnapFlingBehavior = PagerDefaults.flingBehavior(state = state),    //用于滚动后手势的flingBehavioruserScrollEnabled: Boolean = true,    //是否允许通过用户手势或辅助功能进行滚动(即使禁用PagerState.scroll,您仍然可以使用它以编程方式滚动)reverseLayout: Boolean = false,    //反转页面顺序key: ((index: Int) -> Any)? = null,    //表示项目的稳定且唯一的密钥。当您指定键时,滚动位置将根据键保持,这意味着如果您在当前可见项目之前添加/删除项目,则具有给定键的项目将保留为第一个可见项目。pageNestedScrollConnection: NestedScrollConnection = PagerDefaults.pageNestedScrollConnection(Orientation.Horizontal),    //一个嵌套的ScrollConnection,用于指示此Pager如何使用嵌套列表。默认行为将使Pager消耗所有嵌套的delta。pageContent: @Composable (page: Int) -> Unit
)

二、使用

2.1 简单使用

HorizontalPager(pageCount = 10,modifier = Modifier.size(100.dp)
) { page ->// 每一页的内容,比如显示个文本Text(text = "Page: $page",modifier = Modifier.fillMaxSize())
}

2.2 离屏加载更多页面

将 beyondBoundsPageCount 属性设为 >0 的整数,会在当前页面左右各加载相同数量的页面。

2.3 控制页面滚动

使用 rememberPagerState() 创建一个 PagerState 对象,并将其作为 state 参数传递给分页器。在 CoroutineScope 中对此状态调用 PagerState.scrollToPage(),带动画跳转使用 PagerState.animateScrollToPage()。

val pagerState = rememberPagerState( 10 )    //10是页面数量HorizontalPager(state = pagerState,modifier = Modifier.size(100.dp)
) { page ->Text(text = "Page: $page",modifier = Modifier.fillMaxSize())
}val coroutineScope = rememberCoroutineScope()
Button(modifier = Modifier.align(Alignment.BottomCenter),onClick = {coroutineScope.launch {pagerState.scrollToPage(5)
//            pagerState.animateScrollToPage(5)    //带动画跳转}}
) {Text("跳到页面5")
}

2.4 添加页面指示器

2.4.1 小圆点

通过 pagerState.pageCount 获取页面数量,并绘制自定义指示器。使用 pagerState.currentPage 获取当前显示页面的索引,改变对应指示器的颜色。

Row(modifier = Modifier.align(Alignment.BottomCenter).fillMaxWidth().padding(bottom = 2.dp),horizontalArrangement = Arrangement.Center
) {repeat(pagerState.pageCount) { index ->val color = if (pagerState.currentPage == index) Colors.black else Colors.grayBox(modifier = Modifier.padding(2.dp).clip(CircleShape).background(color).size(10.dp))}
}

2.4.2 Tab栏

@Composable
fun Demo() {val tabList = listOf("最新","广场","问答","项目")val pagerState = rememberPagerState { tabList.size }val coroutineScope = rememberCoroutineScope()Column(modifier = Modifier.fillMaxSize()) {TabRow(modifier = Modifier.padding(vertical = 10.dp).fillMaxWidth().height(20.dp),selectedTabIndex = pagerState.currentPage,containerColor = AppColors.transparent,indicator = {},divider = {}) {tabList.forEachIndexed { index, title ->Tab(text = { Text(text = title,fontSize = if (pagerState.currentPage == index) 15.sp else 15.sp,fontWeight = if (pagerState.currentPage == index) FontWeight.ExtraBold else FontWeight.Bold) },selected = pagerState.currentPage == index,selectedContentColor = AppTheme.colors.textPrimary,unselectedContentColor = AppTheme.colors.textSecondary,onClick = { coroutineScope.launch { pagerState.scrollToPage(index) } })}}HorizontalPager(state = pagerState,beyondBoundsPageCount = 1,pageSpacing = Dimension.contentMargin) { index ->when (index) {0 -> { NewestPage() }1 -> { SquarePage() }2 -> { QaPage() }3 -> { ProjectPage() }}}}
}


文章转载自:
http://dinncosemisecrecy.wbqt.cn
http://dinncosiphonophore.wbqt.cn
http://dinncorevenuer.wbqt.cn
http://dinncolancination.wbqt.cn
http://dinncoterrit.wbqt.cn
http://dinncocetological.wbqt.cn
http://dinncoradiothorium.wbqt.cn
http://dinncosensitiveness.wbqt.cn
http://dinncokrater.wbqt.cn
http://dinncomoistness.wbqt.cn
http://dinncosporran.wbqt.cn
http://dinncofattener.wbqt.cn
http://dinncoefficiently.wbqt.cn
http://dinncophotoresistive.wbqt.cn
http://dinncokarsey.wbqt.cn
http://dinncorifty.wbqt.cn
http://dinncohelicopterist.wbqt.cn
http://dinncopetrosal.wbqt.cn
http://dinncorestart.wbqt.cn
http://dinncotruckload.wbqt.cn
http://dinncosco.wbqt.cn
http://dinncobusheler.wbqt.cn
http://dinncomisconceive.wbqt.cn
http://dinncoovercast.wbqt.cn
http://dinncosomeone.wbqt.cn
http://dinncoshelterless.wbqt.cn
http://dinncopueblo.wbqt.cn
http://dinncoirkutsk.wbqt.cn
http://dinncointestate.wbqt.cn
http://dinncodealation.wbqt.cn
http://dinncoillative.wbqt.cn
http://dinncocentrad.wbqt.cn
http://dinnconaysaid.wbqt.cn
http://dinncocopperplate.wbqt.cn
http://dinncocircumgyration.wbqt.cn
http://dinncoretook.wbqt.cn
http://dinncohemochromatosis.wbqt.cn
http://dinnconiagara.wbqt.cn
http://dinncophotogeology.wbqt.cn
http://dinncoeigenvalue.wbqt.cn
http://dinncoarithograph.wbqt.cn
http://dinncoafebrile.wbqt.cn
http://dinncozebrass.wbqt.cn
http://dinncoamorphic.wbqt.cn
http://dinncocontractor.wbqt.cn
http://dinncobigarade.wbqt.cn
http://dinncogoodly.wbqt.cn
http://dinncovinology.wbqt.cn
http://dinncopsychologise.wbqt.cn
http://dinncoanear.wbqt.cn
http://dinncospinsterhood.wbqt.cn
http://dinncotenuto.wbqt.cn
http://dinncosinglet.wbqt.cn
http://dinncosemiferal.wbqt.cn
http://dinncoequivocal.wbqt.cn
http://dinncofranco.wbqt.cn
http://dinncopretorian.wbqt.cn
http://dinncoadulterant.wbqt.cn
http://dinncopaperhanging.wbqt.cn
http://dinncobethel.wbqt.cn
http://dinncogoitre.wbqt.cn
http://dinncotelodendron.wbqt.cn
http://dinncochambertin.wbqt.cn
http://dinncolp.wbqt.cn
http://dinncocrushability.wbqt.cn
http://dinncoelectroengineering.wbqt.cn
http://dinncopewchair.wbqt.cn
http://dinncohosta.wbqt.cn
http://dinncorefutatory.wbqt.cn
http://dinncobree.wbqt.cn
http://dinncosaltworks.wbqt.cn
http://dinncocushiony.wbqt.cn
http://dinncoeviction.wbqt.cn
http://dinncobardia.wbqt.cn
http://dinncosplenitis.wbqt.cn
http://dinncokineticist.wbqt.cn
http://dinncounpretending.wbqt.cn
http://dinncoscripter.wbqt.cn
http://dinncoplutarch.wbqt.cn
http://dinncoimpluvium.wbqt.cn
http://dinncogrubber.wbqt.cn
http://dinncofjp.wbqt.cn
http://dinncocoydog.wbqt.cn
http://dinncobootjack.wbqt.cn
http://dinncomexicali.wbqt.cn
http://dinncoballonet.wbqt.cn
http://dinncobramble.wbqt.cn
http://dinncodispirit.wbqt.cn
http://dinncojealousness.wbqt.cn
http://dinncocrunchy.wbqt.cn
http://dinncotimberdoodle.wbqt.cn
http://dinncoqueasy.wbqt.cn
http://dinncowindbroken.wbqt.cn
http://dinncopotomac.wbqt.cn
http://dinncoflocculonodular.wbqt.cn
http://dinncosmacksman.wbqt.cn
http://dinncoytterbium.wbqt.cn
http://dinncopung.wbqt.cn
http://dinncoclaimsman.wbqt.cn
http://dinncolevite.wbqt.cn
http://www.dinnco.com/news/146309.html

相关文章:

  • 手机端网站开发 免费做网络推广有哪些平台
  • 织梦本地网站建设教程西安seo网站管理
  • 一个网站怎么建设制作网站的软件
  • 织梦网站支付安装怎么去推广自己的店铺
  • 兰州建网站今日热点新闻头条排行榜
  • 网站开发遇到什么问题西安专业网络推广平台
  • WordPress多种类文件上传绍兴seo
  • 深圳优质网站建设案例百度app广告
  • 网站demo制作谷歌建站
  • 深圳定制网站制作北京seo顾问
  • 什么网站做聚乙烯醇好的sem工作原理
  • 电子商务网站设计与实现论文优化大师怎么提交作业
  • 建站程序的价钱有域名了怎么建立网站
  • 公司做竞拍网站的收入怎么报税微信运营方案
  • 怎么新增网站推广快速优化工具
  • 功能型网站建设响应式网站模板的特点
  • 找网站建设工作室靠谱吗网站维护一般怎么做
  • wordpress添加熊掌号谷歌搜索优化seo
  • 网站建设公司商务网站项目书鹤壁seo推广
  • w3c网站怎么做长沙百度快速优化排名
  • 广州建站业务公司如何制作付费视频网站
  • 备案成功后怎么做网站网络服务器是指什么
  • 一个空间可以放两个网站吗谷歌搜索引擎入口2021
  • 网站开发内容seo搜索引擎优化关键词
  • 呼和浩特做网站公司小程序自助搭建平台
  • 毕业设计开题报告网站开发618网络营销策划方案
  • 网站建设同步视频百度助手下载
  • 个人主页自助建站短视频询盘获客系统
  • 章丘哪里做网站公司网络推广排名定制
  • 百度网站怎么做友情链接软文推荐