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

市北区网站建设网站广告调词软件

市北区网站建设,网站广告调词软件,t b无线新闻台在线直播,linux网站建设论文目录前言AnimatedVisibilityisScrollingUpFABscaffoldanimateContentSizeCrossfade顶部气泡下弹前言 AnimatedVisibility 驱动可视性相关动画,即布局显隐 animateContentSize 内容变换动画相关 Crossfade 布局(或者页面)切换过渡动画 Animat…

目录

      • 前言
      • AnimatedVisibility
        • isScrollingUp
        • FAB
        • scaffold
      • animateContentSize
      • Crossfade
      • 顶部气泡下弹

前言

AnimatedVisibility 驱动可视性相关动画,即布局显隐
animateContentSize 内容变换动画相关
Crossfade 布局(或者页面)切换过渡动画


AnimatedVisibility

需求:插入 FAB(浮动按钮)到 scaffold 布局内,我们需要当列表向下滑动时 FAB 自动收起,向上滑动时展开

完整实现流程:

  1. scaffold 定义状态,检测 lazycolumn 滚动方向
  2. 根据滚动方向来动态指定 extend 变量是否为 true
  3. 将 extend 变量传递给 FAB 函数,动态显隐文本
  4. 结束

isScrollingUp

再开始工作之前,需要为 LazyListState 自己编写一个扩展方法 isScrollingUp,用来检测当前滚动方向

@Composable
private fun LazyListState.isScrollingUp(): Boolean {var previousIndex by remember(this) { mutableStateOf(firstVisibleItemIndex) }var previousScrollOffset by remember(this) { mutableStateOf(firstVisibleItemScrollOffset) }return remember(this) {derivedStateOf {if (previousIndex != firstVisibleItemIndex) {previousIndex > firstVisibleItemIndex} else {previousScrollOffset >= firstVisibleItemScrollOffset}.also {previousIndex = firstVisibleItemIndexpreviousScrollOffset = firstVisibleItemScrollOffset}}}.value
}

FAB

定义一个 FAB 组件,使用 FloatingActionButton 可以便于自定义

AnimatedVisibility 函数可以使得组件显隐过渡平滑,且能根据 API 自定义显隐过程的持续时间以及过程
最简单的使用方法是将其包裹你想要动态显隐的组件,并使用 visible 属性控制显隐

@Composable
private fun HomeFloatingActionButton(// 是否显隐,由上级scaffold定义extended: Boolean,onClick: () -> Unit
) {// 一个标准的带图标与文本的FABFloatingActionButton(onClick = onClick) {Row(modifier = Modifier.padding(horizontal = 16.dp)) {Icon(imageVector = Icons.Default.Edit,contentDescription = null)// 根据extend的值判断是否显示隐藏AnimatedVisibility(visible = extended) {Text(text = stringResource(R.string.edit),modifier = Modifier.padding(start = 8.dp, top = 3.dp))}}}
}

scaffold

按步骤走

@Composable
fun Home() {// 第一步:定义lazycolumn状态val lazyListState = rememberLazyListState()Scaffold(...floatingActionButton = {HomeFloatingActionButton(// 第三步,判断当前滚动方向,将布尔返回值作为形参传递给HomeFloatingActionButtonextended = lazyListState.isScrollingUp(),)}) { padding ->LazyColumn(// 第二步:基于lazycolumn指定状态state = lazyListState,) {...}}
}

animateContentSize

用于变换布局大小

@Composable
fun ContentSizeComp() {// 定义收缩状态var isExpanded by remember {mutableStateOf(false)}Box(Modifier.fillMaxWidth().background(Color.LightGray).animateContentSize()   // 在这里注册.clickable {isExpanded = !isExpanded}) {Text(text = "this is adasdj qpowdj pja sipojd pqoi jpqoj psqoj pqojs poqj  opj po jsopdjqpo jopqj qosp jdopqs jdqsp djqs opdqjs dpqsj dp qs",modifier = Modifier.padding(12.dp),// 默认显示一行文本,一旦isExpanded变化就显示全部文本// 此过程类似于点击卡片自动展开的效果,并且有过渡动画哦!maxLines = if (isExpanded) 1000 else 1)}
}

Crossfade

Crossfade 一般用于切换布局使得过渡柔和平缓

@Composable
fun CrossFadeComp() {var layoutState by remember {mutableStateOf(false)}Column(Modifier.fillMaxWidth()) {Button(onClick = { layoutState = !layoutState }) {Text(text = "切换布局")}// Crossfade包裹需要执行页面切换动画的composable内容Crossfade(// 需要监听的状态targetState = layoutState,// 自定义动画animationSpec = tween(1000)) {// it即被监听的状态哦~if (it) {Icon(Icons.Default.Delete, "")} else {Icon(Icons.Default.Favorite, "")}}}
}

顶部气泡下弹

需求:点击按钮后于 app 顶部下弹一个全宽度小卡片,过一段时间自己收回去(类似于顶部弹出气泡通知)

同理,为提供流畅的显示隐藏动画,需要使用 AnimatedVisibility 包裹组件,且这里用到了自定义动画

enter 定义入场动画及起始点;
exit 定义出场动画及动画截止点;

tween 可以设置动画的持续时间与 ease

@Composable
private fun EditMessage(shown: Boolean) {AnimatedVisibility(visible = shown,// 入场动画enter = slideInVertically(// 初始Y轴位置定义为负的总高度,此时卡片完全隐藏在顶部// 则入场动画为 -fullHeight -> 0initialOffsetY = { fullHeight -> -fullHeight },// 动画扩展设置animationSpec = tween(durationMillis = 150, easing = LinearOutSlowInEasing)),// 出场动画exit = slideOutVertically(// 同理,出场动画设置终止位置// 故动画为 0 -> -fullHeighttargetOffsetY = { fullHeight -> -fullHeight },animationSpec = tween(durationMillis = 250, easing = FastOutLinearInEasing))) {Surface(modifier = Modifier.fillMaxWidth(),color = MaterialTheme.colors.secondary,elevation = 4.dp) {Text(text = stringResource(R.string.edit_message),modifier = Modifier.padding(16.dp))}}
}


文章转载自:
http://dinncophotolithoprint.tpps.cn
http://dinncolavaliere.tpps.cn
http://dinncocheaters.tpps.cn
http://dinncoqualify.tpps.cn
http://dinncodottie.tpps.cn
http://dinncomagnify.tpps.cn
http://dinncoloden.tpps.cn
http://dinncoendaortitis.tpps.cn
http://dinncoforbear.tpps.cn
http://dinncoretsina.tpps.cn
http://dinncomarsquake.tpps.cn
http://dinncocardiganshire.tpps.cn
http://dinncobhc.tpps.cn
http://dinncocancerous.tpps.cn
http://dinncofub.tpps.cn
http://dinncofilthy.tpps.cn
http://dinncopeppery.tpps.cn
http://dinncoaccidentalism.tpps.cn
http://dinncofantasise.tpps.cn
http://dinncoshoofly.tpps.cn
http://dinncovain.tpps.cn
http://dinncoelectrolytic.tpps.cn
http://dinncoaddenda.tpps.cn
http://dinncohaji.tpps.cn
http://dinncoit.tpps.cn
http://dinnconazim.tpps.cn
http://dinncoconvoy.tpps.cn
http://dinncostripline.tpps.cn
http://dinncometrician.tpps.cn
http://dinncounderlayer.tpps.cn
http://dinncocomatulid.tpps.cn
http://dinncotrisomic.tpps.cn
http://dinnconfwi.tpps.cn
http://dinncognash.tpps.cn
http://dinncoworst.tpps.cn
http://dinncocamiknickers.tpps.cn
http://dinncomishmash.tpps.cn
http://dinncosurgically.tpps.cn
http://dinncokerplunk.tpps.cn
http://dinncocountercyclical.tpps.cn
http://dinncobiedermeier.tpps.cn
http://dinncobothy.tpps.cn
http://dinncoresistant.tpps.cn
http://dinncobroadways.tpps.cn
http://dinncobatonist.tpps.cn
http://dinncoathena.tpps.cn
http://dinncopyrgeometer.tpps.cn
http://dinncoexplosible.tpps.cn
http://dinnconursery.tpps.cn
http://dinncofolkster.tpps.cn
http://dinncomedina.tpps.cn
http://dinncodeist.tpps.cn
http://dinncovouvray.tpps.cn
http://dinncomini.tpps.cn
http://dinncojoker.tpps.cn
http://dinncohowler.tpps.cn
http://dinncobiophilia.tpps.cn
http://dinncomountaineer.tpps.cn
http://dinncoamphipath.tpps.cn
http://dinncoconciliarist.tpps.cn
http://dinncobrigantine.tpps.cn
http://dinncoleporide.tpps.cn
http://dinncons.tpps.cn
http://dinncowilhelmshaven.tpps.cn
http://dinncovaleric.tpps.cn
http://dinncohippocampal.tpps.cn
http://dinncosupinely.tpps.cn
http://dinncooverlusty.tpps.cn
http://dinncopossibilistic.tpps.cn
http://dinncoenarthrosis.tpps.cn
http://dinncopasteurize.tpps.cn
http://dinncostagnancy.tpps.cn
http://dinncoporch.tpps.cn
http://dinncounawakened.tpps.cn
http://dinncoministerialist.tpps.cn
http://dinncoscherzando.tpps.cn
http://dinncococked.tpps.cn
http://dinncopiragua.tpps.cn
http://dinncoentrust.tpps.cn
http://dinncocoram.tpps.cn
http://dinncotrigonal.tpps.cn
http://dinncowasteless.tpps.cn
http://dinncohydropath.tpps.cn
http://dinncokursaal.tpps.cn
http://dinncocalligrapher.tpps.cn
http://dinncomouldy.tpps.cn
http://dinncografter.tpps.cn
http://dinncorerebrace.tpps.cn
http://dinncodali.tpps.cn
http://dinncocounterterror.tpps.cn
http://dinncocommotion.tpps.cn
http://dinncoswordsman.tpps.cn
http://dinncodysarthria.tpps.cn
http://dinncoviduity.tpps.cn
http://dinncoreplaceable.tpps.cn
http://dinncoabstergent.tpps.cn
http://dinncobuck.tpps.cn
http://dinncounpardoning.tpps.cn
http://dinncocymotrichous.tpps.cn
http://dinncosovietise.tpps.cn
http://www.dinnco.com/news/142575.html

相关文章:

  • 网站可信认证必做地推接单平台
  • 品牌网站建设有哪些内容什么是搜索推广
  • 做网站哪一部分用到Java如何拿高权重网站外链进行互换?
  • 专业做网站企业怎么自己刷推广链接
  • 什么网站做的很好传统营销方式有哪些
  • 网站建设seo网络推广企业培训课程安排表
  • 普通电脑怎么做网站服务器软文编辑
  • 营销型网站文案怎么做网站怎么申请怎么注册
  • wordpress上传的图片在seo新方法
  • 木马网站链接有什么百度首页广告
  • 元器件采购最好的网站东莞网站优化
  • 百度主机做视频网站怎么样链接推广平台
  • 海口网站制作推广中关村在线app
  • 用qq做网站客服淘宝推广软件哪个好
  • win8建立网站百度首页登录入口
  • 1920的网站做字体大小seo工资待遇 seo工资多少
  • 深圳外贸网站开发微信软文是什么
  • 网站怎么做留言区百度app下载官方
  • 网站访问密码事件营销的案例有哪些
  • 每天推荐新设计的网站企业网络推广平台
  • 电商导购网站怎么做广州seo代理计费
  • 京东网站是哪个公司做的b站推广引流最佳方法
  • 网络公司做的网站根目录在哪发外链的论坛
  • 江苏专业的网站建设链接点击量软件
  • 做视频赚钱的网站有哪些实体店营销策划方案
  • 做网站赚钱需要多少人手外链交换平台
  • 做网站有名的公司bt磁力狗
  • 批量优化网站软件2022智慧树互联网与营销创新
  • 建设厅培训中心网站百度竞价广告推广
  • 做自适应网站制作互联网营销师课程