Android---Chip
Chip
Chip 代表一个小块中的复杂实体,如联系人。它是一个圆形按钮,由一个标签,一个可选的芯片图标和一个可选的关闭图标组成。如果 Chip 可检查,则可以点击或切换Chip 。
style="@style/Widget.MaterialComponents.Chip.Action": 默认样式,是一个普通标签,点击后没有任何特殊效果。
style="@style/Widget.MaterialComponents.Chip.Entry": 默认一直末尾展示删除按钮;点击后前面展示选中图标,有选中状态,通常可以作为 chipDrawable 使用,比如在填选邮件收件人时可以使用;
style="@style/Widget.MaterialComponents.Chip.Filter" 初始状态下,不展示前后图标,点击后会展示前面选中的图标,并且具有选中状态,通常应用在 ChipGroup 中;
style="@style/Widget.MaterialComponents.Chip.Choice" 具有选中效果,前后没有图标,点击后有选中颜色变化效果。
Chip 基本属性:
类别 | 属性名称 | 具体作用 |
Shape | app:chipCornerRadius | 圆角半径 |
Size | app:chipMinHeight | 最小高度 |
Background | app:chipBackgroudColor | 背景颜色 |
Border | app:chipStrokeColor | 边线颜色 |
Border | app:chipStrokeWidth | 边线宽度 |
Ripple | app:rippleColor | 水波纹颜色 |
Label | android:text | 文本内容 |
Label | androi:textAppearance | 字体样式 |
Label | android:textColor | 修改文本颜色 |
Chip Icon | app:chipIconVisible | 前面图标是否显示 |
Chip Icon | app:chipIconSize | chip中文字前面的图标 |
Chip Icon | app:chipIconTint | 文字前面的图标着色 |
Close Icon | app:closeIconVisible | chip中文字后面关闭按钮是否可见 |
Close Icon | app:closeIcon | chip中文字后面的关闭图标 |
Close Icon | app:closeIconSize | 文字后面的关闭图标的大小 |
Close Icon | app:closeIconTInt | 文字后面的着色 |
Checkable | app:checkable | 是否可以被选中 |
Checked Icon | app:checkedIconVisible | 选中状态的图标是否可见 |
Checked Icon | app:checkedIcon | 选中状态的图标 |
Motion | app:showMotionSepc | 动效? |
Motion | app:hiheMotoinSpec | 动效? |
Paddings | app:chipStartPading | chip左边距 |
Paddings | app:chipEndPading | chip右边距 |
Paddings | app:iconStartPading | chipIcon的左边距 |
Paddings | app:iconEndPading | chipIcon的右边距 |
Paddings | app:textStartPading | 文本左边距 |
Paddings | app:textEndPading | 文本右边距 |
Paddings | app:CloseIconStartPading | 关闭按钮的左边距 |
Paddings | app:closeIconEndPading | 关闭按钮的右边距 |
ChipGroup
Chip 可以被放置在 ChipGroup 中,可以实现流逝布局(以前只能通过自定义 view 实现)。该组件合 RadioGroup 很相似,都是用来管理多个子 View 的,可以控制内部子 View 的布局方式。默认情况下,里面的 Chip 是横向多行排列的,每行的最后一个 Chip 控件如果放不下的时候就会自动换行,符合流式布局的规则。
ChipGroup 基本属性:
app:checkedChip: 设置初始默认选中的 chip;
app:chipSpacing: 设置 Chip 间的间距,如果有 app:chipSpacingHorizontal 或者 app:chipSpacingVertical 属性,chipSpacing 属性会被覆盖;
app:chipSpacingHorizontal: 设置 Chip 之间的水平间距,优先级高于 app:chipSpacing;
app:chipSpacingVertiacl: 设置 Chip 之间的垂直间距,优先级高于 app:chipSpacing;
app:singleLing: 设置是否开启单行模式;
app:singleSelection: 设置是否开启单选模式,默认是多选。
xml 布局:
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollViewxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:layout_width="match_parent"android:layout_height="match_parent"tools:context=".MainActivity"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical"><com.google.android.material.chip.Chipandroid:id="@+id/chip0"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="还我星星"/><com.google.android.material.chip.Chipandroid:id="@+id/chip1"style="@style/Widget.MaterialComponents.Chip.Entry"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="别偷我的猪"/><com.google.android.material.chip.Chipandroid:id="@+id/chip2"style="@style/Widget.MaterialComponents.Chip.Filter"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="一块硬币"/><com.google.android.material.chip.Chipandroid:id="@+id/chip3"style="@style/Widget.MaterialComponents.Chip.Choice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="HLLXY"/><com.google.android.material.chip.Chipandroid:id="@+id/chip4"style="@style/Widget.MaterialComponents.Chip.Action"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="HLLWY"/><com.google.android.material.chip.ChipGroupandroid:layout_width="match_parent"android:layout_height="wrap_content"app:chipSpacingHorizontal="25dp"app:checkedChip="@+id/first"app:selectionRequired="true"app:singleSelection="true"><com.google.android.material.chip.Chipandroid:id="@+id/first"style="@style/Widget.MaterialComponents.Chip.Choice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="还我星星1"/><com.google.android.material.chip.Chipstyle="@style/Widget.MaterialComponents.Chip.Choice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="还我星星2"/><com.google.android.material.chip.Chipstyle="@style/Widget.MaterialComponents.Chip.Choice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="还我星星3"/><com.google.android.material.chip.Chipstyle="@style/Widget.MaterialComponents.Chip.Choice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="还我星星4"/><com.google.android.material.chip.Chipstyle="@style/Widget.MaterialComponents.Chip.Choice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="还我星星5"/><com.google.android.material.chip.Chipstyle="@style/Widget.MaterialComponents.Chip.Choice"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="还我星星6"/></com.google.android.material.chip.ChipGroup></LinearLayout></androidx.core.widget.NestedScrollView>
参考博客:芝麻粒儿 的CSDN
Android---Chip相关推荐
- Android:Chip、ChipGroups、ChipDrawable
文中完整代码下载地址:https://github.com/CnPeng/CnPengAndroid2.git 文中内容对应上述地址中的 a01_chips 目录 此外,文中DEMO是基于 Andro ...
- 支持linux的usb无线网卡芯片,Realtek RTL8188CUSamp;RTL8188ETV 型芯片USB无线网卡驱动程序for Linuxamp;Android...
[实例简介] Realtek RTL8188CUS&RTL8188ETV 型芯片USB无线网卡驱动程序for Linux&Android 内附详细说明文档.可用于嵌入式Linux an ...
- chips cope_Android P:Chips and ChipGroup
chips cope In this tutorial, we'll be discussing the latest components that are a part of the new Ma ...
- 【Android,CustomWidget】Chip:那些搜索记录和好评中的Chips组件
Android,CustomWidget.Chip:那些搜索记录和好评中的Chips组件 # 效果 # 实现 # 使用 # Github支持 # 效果 有时我们在做搜索组件的时候, 会有搜索历史的展示 ...
- Android修行手册 - Chip监听和ChipGroup监听
往期文章分享 点击跳转=><导航贴>- Unity手册,系统实战学习 点击跳转=><导航贴>- Android手册,重温移动开发 本文约5.8千字,新手阅读需要11 ...
- Android上成功实现了蓝牙的一些Profile
前段时间做蓝牙方面的开发,Google的Android只实现了Handset/Handfree和A2DP/AVRCP等Profile,而其 它常用的Profile如HID/DUN/SPP/OPP/FT ...
- 【转】android电池(四):电池 电量计(MAX17040)驱动分析篇
关键词:android 电池 电量计 MAX17040 任务初始化宏 power_supply 平台信息: 内核:linux2.6/linux3.0 系统:android/android4.0 ...
- android下调试声卡驱动之概述
在Android中音频系统使用的是ALSA系统架构.ASoC--ALSA System on Chip .是建立在标准ALSA驱动层上,为了更好地支持 嵌入式处理器和移动设备中的音频Codec的一套软 ...
- 高通android开发摘要
一部分是开源的,可以从codeaurora.org上下载,还有一部分是高通产权的,需要从高通的网站上下载. 将高通产权的代码放到:vendor/qcom/proprietary 1. 设置bms一些参 ...
- android的各种*.img 文件
关于android的各种disk images 对android的各种disk images很好奇,一直想知道怎么去know和hack这些images,所以就有了这篇paper. 用file来查看文件 ...
最新文章
- Ubuntu 14.04 64bit + CUDA 6.5 配置说明
- 参观中央财经大学机房安装centos6.4及优化小结
- Winform中设置ZedGraph的多条Y轴的标题和刻度不显示十次幂
- shell 命令 链接文件 ln
- 惠普与4PS联络中心国际标准组织达成战略合作
- redis事务乐观锁,watch
- 韩国FSC公布新方案允许分离银行加密业务 以帮助小型交易所继续运营
- React antD-Pro 添加函数防抖
- KMP算法 --- 在文本中寻找目标字符串
- web服务器通信原理
- 感人至深:40岁博士毕业,新任安徽省长王清宪的博士论文后记
- 一个开关电源PCB Layout设计流程
- H5点击复制按钮复制文本
- android USB OTG功能如何打开及实现
- 上海率先开放政府数据 医院床位车位信息均可查
- 没键盘计算机能启动吗,实现PC电脑无键盘鼠标开机
- 用python画一个笑脸_python画个笑脸
- 安装好maya后运行不了并弹出如图的错误
- 网页瘦身方法-金瑞帆高端建站
- ORACLE —— 事务
热门文章
- Linux命令 ——timeout
- 更改eclipse注释的颜色
- 常见容错机制:failover ,failsafe,failfase ,failback,forking
- sonnoc索诺克投影仪无法输出画面,提示“输入信号超出输出范围 调整为1920X1080@60Hz“
- OpenCV安装配置教程VS2022(超级顺利)
- MCE公司:探索翻译后修饰的新工具
- mysql 字符集设置 重启
- 线性回归之随机梯度下降法(Stochastic Gradient Descent,SGD)
- 2017 年度码云新增项目排行榜 TOP 50,为它们打“call”
- Win10蓝屏问题:SYSTEM_THREAD_EXCEPTION_NOT_HANDLED