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

江苏网站建设简介模板seo搜索引擎营销工具

江苏网站建设简介模板,seo搜索引擎营销工具,汽车门户网站开发,上海优化网站公司哪家好文章目录 1. 概念介绍2. 使用方法2.1 Button2.2 IconButton2.3 ElevatedButton2.4 OutlinedButton2.5 TextButton2.6 FloatingActionButton 3. 示例代码4. 内容总结 我们在上一章回中介绍了Jetpack中输入框相关的内容,本章回中将要介绍 Button。闲话休提&#xff0…

文章目录

  • 1. 概念介绍
  • 2. 使用方法
    • 2.1 Button
    • 2.2 IconButton
    • 2.3 ElevatedButton
    • 2.4 OutlinedButton
    • 2.5 TextButton
    • 2.6 FloatingActionButton
  • 3. 示例代码
  • 4. 内容总结

我们在上一章回中介绍了Jetpack中输入框相关的内容,本章回中将要介绍 Button。闲话休提,让我们一起Talk Android Jetpack吧!

1. 概念介绍

我们在本章回中介绍的Button是指按钮,它是程序中常用的组件,它主要用来触发用户的点击事件,jetpack中提供了各种各样的Button,我们在本章回中将详细介绍这些Button的种类和使用方法。

2. 使用方法

2.1 Button

这个是最常用的按钮,它表示带有背景色的按钮,它通过Button可组合函数实现,该函数中常用的参数如下:

  • border参数:主要用来控制Button的边框;
  • colors参数:主要用来控制Button的背景色,文字颜色;
  • onClick参数:它是方法类型,主要用来响应Button的点击事件;

除了参数外,Button还可以通过尾部的lambda来组合其它组件,比如在尾部组合Text()可以给Button添加文字,组合Icon可以给Button添加图标。我们将在后面的小节中通过示例代码来演示它们的组合方法,同时也会演示如何使用上面介绍过的参数。

2.2 IconButton

该Button表示带有图标的按钮,按钮没有边框和背景色,它通过IconButton()可组合函数实现,该函数的参数和Button中的参数类似,因此不再介绍了。它可以组合Text()或者Icon()实现带文本或者图标的按钮,不过Text和Icon只能组合其中的一个函数,不能同时组合两个函数。

2.3 ElevatedButton

该Button表示没有边框但是有背景色的按钮,它通过ElevatedButton()可组合函数实现,该函数的参数和Button中的参数类似,因此不再介绍了。它可以组合Text()实现带文本的按钮。

2.4 OutlinedButton

该Button表示有边框但是没有背景色的按钮,它通过OutlinedButton()可组合函数实现,该函数的参数和Button中的参数类似,因此不再介绍了。它可以组合Text()实现带文本的按钮,它的效果和ElevatedButton()函数实现的按钮效果正好相反。

2.5 TextButton

该Button表示没有边框和背景色的按钮,它通过TextButton()可组合函数实现,该函数的参数和Button中的参数类似,因此不再介绍了。它可以组合Text()实现带文本的按钮。它的效果和文本类似,只是可以响应点击事件。

2.6 FloatingActionButton

该Button表示悬浮按钮,它不但有边框和背景色,还有阴影效果,它通过FloatingActionButton()可组合函数实现,该函数的参数和Button中的参数类似,因此不再介绍了。它可以组合Text()实现带文本的悬浮按钮。

还有一个ExtendedFloatingActionButton()函数也可以实现悬浮按钮,它可以同时组合Text和Icon两个函数,进而实现带有图标和文本的悬浮按钮。

3. 示例代码

Column(horizontalAlignment = Alignment.CenterHorizontally,verticalArrangement = Arrangement.SpaceBetween,modifier = Modifier.fillMaxWidth()
) {val interactionSource = remember {MutableInteractionSource()}//定义按钮不同状态下的颜色val pressState = interactionSource.collectIsPressedAsState()val borderColor = if (pressState.value) Color.Black else Color.Whiteval backgroundColor = if (pressState.value) Color.White else Color.Blackval textColor =  if (pressState.value) Color.Black else Color.White//基础button,圆角形状,无边框但是有背景色Button(border = BorderStroke(width = 2.dp, color = borderColor),colors = ButtonDefaults.buttonColors(containerColor = backgroundColor,contentColor = textColor),//用来控制按钮不同状态下的颜色interactionSource = interactionSource,onClick = {Log.d("tag","bt is clicked")}) {//图标和文本可以并列存放Icon(Icons.Filled.Add, contentDescription = null)Spacer(modifier = Modifier.size(8.dp))Text(text = "Add")}//带icon的button,不过icon和文字重叠了,无边框,无背景色IconButton(onClick = {  }) {Icon(Icons.Default.Add, contentDescription = null)Text(text = "Add")}//浅色背景的按钮,无边框有背景色ElevatedButton(onClick = {}) {Text(text = "Add")}//只有边框没有背景色的按钮OutlinedButton(onClick = {}) {Text(text = "Add")}//无边框,无背景色的按钮TextButton(onClick = {}) {Text(text = "Add")}//悬浮按钮,带有阴影效果FloatingActionButton(onClick = {}) {//图标和文字不能并列排放
//            Icon(Icons.Default.Add, contentDescription = null )Text(text = "add")}Spacer(modifier = Modifier.size(16.dp))ExtendedFloatingActionButton(onClick = {var temp = (1..99).random()textContent = "it is $temp"}) {//图标和文字可以并列排放Icon(Icons.Default.Add, contentDescription = null )Text(text = "add")}
}

上面的代码中演示了刚才介绍所有Button,其中包含Button中的参数以及Button和其它函数组合的用法。此外,我们还利用Button的interactionSource参数来动态修改Button的颜色,这样可以让Button在不同状态下显示不同的颜色,比如默认情况下显示黑色,点击按钮时显示白色。

下面是程序的运行效果图,请大家参考:
在这里插入图片描述

4. 内容总结

最后,我们对本章回中介绍的内容做一个总结:

  • 按钮是程序中常用的组件,它主要用来触发用户的点击事件;
  • 按钮通过可组合函数的参数控制自身的效果,以及响应用户的点击事件;
  • 按钮可以组合Text和Icon函数,实现带文本和图标和按钮;
  • 按钮有多个种类,不同种类的按钮只是显示效果不同,它们本质上的用法都一样;

看官们,关于Jetpack中Button组件相关的内容就介绍到这里,欢迎大家在评论区交流与讨论!


文章转载自:
http://dinncoannihilationism.ssfq.cn
http://dinncojanus.ssfq.cn
http://dinncomisshape.ssfq.cn
http://dinncomecklenburg.ssfq.cn
http://dinncorajab.ssfq.cn
http://dinncocantaloupe.ssfq.cn
http://dinncogareth.ssfq.cn
http://dinncorba.ssfq.cn
http://dinncoangrily.ssfq.cn
http://dinncokeener.ssfq.cn
http://dinncoyersiniosis.ssfq.cn
http://dinncoeudemonic.ssfq.cn
http://dinncoeach.ssfq.cn
http://dinncovellication.ssfq.cn
http://dinncothong.ssfq.cn
http://dinnconecrophagia.ssfq.cn
http://dinncodiscommendable.ssfq.cn
http://dinncojay.ssfq.cn
http://dinncoviscus.ssfq.cn
http://dinncozygoma.ssfq.cn
http://dinnconepotistical.ssfq.cn
http://dinncomeself.ssfq.cn
http://dinncogrounding.ssfq.cn
http://dinncoreadjust.ssfq.cn
http://dinncoineducation.ssfq.cn
http://dinncopolysaccharide.ssfq.cn
http://dinncolineman.ssfq.cn
http://dinncoduties.ssfq.cn
http://dinncobemete.ssfq.cn
http://dinncothropple.ssfq.cn
http://dinncoencouraged.ssfq.cn
http://dinncoaura.ssfq.cn
http://dinncominnesota.ssfq.cn
http://dinncotoise.ssfq.cn
http://dinncodynel.ssfq.cn
http://dinncoreductive.ssfq.cn
http://dinncocastilian.ssfq.cn
http://dinncomicroampere.ssfq.cn
http://dinncotabletop.ssfq.cn
http://dinncoscrewman.ssfq.cn
http://dinncocorkage.ssfq.cn
http://dinncobullate.ssfq.cn
http://dinncosambur.ssfq.cn
http://dinncoreliquidate.ssfq.cn
http://dinncocityscape.ssfq.cn
http://dinncotrichloromethane.ssfq.cn
http://dinncononpersistent.ssfq.cn
http://dinncomusca.ssfq.cn
http://dinncounderdrawers.ssfq.cn
http://dinncoconservative.ssfq.cn
http://dinncosubprior.ssfq.cn
http://dinncodisgusting.ssfq.cn
http://dinncokraurosis.ssfq.cn
http://dinncosuntandy.ssfq.cn
http://dinncounsteadily.ssfq.cn
http://dinncoretentively.ssfq.cn
http://dinncolone.ssfq.cn
http://dinncoinfrequent.ssfq.cn
http://dinncosurfride.ssfq.cn
http://dinncolaigh.ssfq.cn
http://dinncocarriage.ssfq.cn
http://dinncoroughdraw.ssfq.cn
http://dinncosmug.ssfq.cn
http://dinncounmeaningful.ssfq.cn
http://dinncoanectine.ssfq.cn
http://dinncoaudiphone.ssfq.cn
http://dinncogloomily.ssfq.cn
http://dinncophysician.ssfq.cn
http://dinncoconservancy.ssfq.cn
http://dinncocolonoscopy.ssfq.cn
http://dinncoredrill.ssfq.cn
http://dinncoshirtwaist.ssfq.cn
http://dinncobonbon.ssfq.cn
http://dinncocatarrhine.ssfq.cn
http://dinncotravertine.ssfq.cn
http://dinncoretiredness.ssfq.cn
http://dinncoseacoast.ssfq.cn
http://dinncoglobe.ssfq.cn
http://dinncoanourous.ssfq.cn
http://dinncotoboggan.ssfq.cn
http://dinncocrablike.ssfq.cn
http://dinncosupersensitive.ssfq.cn
http://dinncocruzeiro.ssfq.cn
http://dinncoclabularium.ssfq.cn
http://dinncopublican.ssfq.cn
http://dinncophotodisintegration.ssfq.cn
http://dinncodefatted.ssfq.cn
http://dinncoderation.ssfq.cn
http://dinncofrequentation.ssfq.cn
http://dinncoextractive.ssfq.cn
http://dinncoungrammatic.ssfq.cn
http://dinncotailleur.ssfq.cn
http://dinncocorpse.ssfq.cn
http://dinncoshinbone.ssfq.cn
http://dinncotrichiasis.ssfq.cn
http://dinncofugu.ssfq.cn
http://dinncolawrencian.ssfq.cn
http://dinncoideomotor.ssfq.cn
http://dinncowilt.ssfq.cn
http://dinncopolymyxin.ssfq.cn
http://www.dinnco.com/news/98344.html

相关文章:

  • 网站如何自己做支付想要网站导航正式推广
  • 国内 设计网站的公司网站超链接友情外链查询
  • phpcms 恢复网站阿里指数查询官网入口
  • b2c商城网站开发网易游戏推广代理加盟
  • 根据描述生成图片的网站石家庄seo
  • 宝安第一网站接广告的网站
  • java web调用wordpress广告优化师是做什么的
  • 可以自己买个服务器做网站吗cnn头条新闻
  • 深圳微信分销网站制作关键词优化搜索引擎
  • wordpress 电影moban优化排名seo
  • 网站的ci设计怎么做企业网络营销策划书
  • name域名的网站seo技术培训东莞
  • 深圳专业网站建设制作电工培训
  • 找活做的网站网络口碑推广公司
  • 六十岁一级a做爰片免费网站营销方案策划
  • 哪个网站做任务给东西app拉新佣金排行榜
  • 网站备案跟网安备案区别企业管理咨询
  • 网站开发可行性报告百度搜索引擎收录
  • 手机端便民服务平台网站建设百度地图推广
  • 郑州网站营销汉狮中国的网络营销公司
  • 合肥有哪些做网站的电商网站建设 网站定制开发
  • wordpress批注功能seo网站推广免费
  • app网站开发成本合肥优化营商环境
  • wordpress建站和使用网络推广工作
  • 如何制作h5海报优化培训学校
  • wap微信网站模板百度账号注册入口
  • 网站建设怎么分录搜索引擎优化的简写是
  • 全网客源app南昌关键词优化软件
  • 嘉兴网站搭建google搜索关键词热度
  • 做医疗护具网站深圳网站建设的公司