android:spacing="16dp",GitHub - adroitandroid/ChipCloud: Android UI library that creates material 'c...

ChipCloud是一个快速创建Android Chip视图的库,用于在一个Hackathon项目中展示材料设计的'Chips'。本文档详细介绍了如何通过XML和代码配置ChipCloud,包括颜色、字体、过渡效果、选择模式和重力等属性,并提供了动态添加和更新标签的示例。此外,还介绍了多种选择模式和重力选项,以及如何设置选定的索引。
摘要由CSDN通过智能技术生成

ChipCloud

The ChipCloud library was originally a (very) quickly knocked up Android view for some larger hackathon project by fiskurgit. It creates a wrapping cloud of material 'Chips'. Basic demo of their version is available on the Play Store - I'm maintaining this fork for features I required in it.

5cbe0efb2087a539ff9808e4df7e2660.png

Usage

Add to your Android layout xml:

android:id="@+id/chip_cloud"

android:layout_width="match_parent"

android:layout_height="wrap_content"/>

Configure in xml:

xmlns:chipcloud="http://schemas.android.com/apk/res-auto"

android:id="@+id/chip_cloud"

android:layout_width="match_parent"

android:layout_height="wrap_content"

chipcloud:deselectedColor="@color/deselected_color"

chipcloud:deselectedFontColor="@color/deselected_font_color"

chipcloud:selectedColor="@color/selected_color"

chipcloud:selectedFontColor="@color/selected_font_color"

chipcloud:deselectTransitionMS="500"

chipcloud:selectTransitionMS="750"

chipcloud:labels="@array/labels"

chipcloud:selectMode="required"

chipcloud:allCaps="true"

chipcloud:gravity="staggered"

chipcloud:minHorizontalSpacing="32dp"

chipcloud:verticalSpacing="16dp"

chipcloud:textSize="14sp"

chipcloud:typeface="RobotoSlab-Regular.ttf"/>

or in code:

ChipCloud chipCloud = (ChipCloud) findViewById(R.id.chip_cloud);

new ChipCloud.Configure()

.chipCloud(chipCloud)

.selectedColor(Color.parseColor("#ff00cc"))

.selectedFontColor(Color.parseColor("#ffffff"))

.deselectedColor(Color.parseColor("#e1e1e1"))

.deselectedFontColor(Color.parseColor("#333333"))

.selectTransitionMS(500)

.deselectTransitionMS(250)

.labels(someStringArray)

.mode(ChipCloud.Mode.MULTI)

.allCaps(false)

.gravity(ChipCloud.Gravity.CENTER)

.textSize(getResources().getDimensionPixelSize(R.dimen.default_textsize))

.verticalSpacing(getResources().getDimensionPixelSize(R.dimen.vertical_spacing))

.minHorizontalSpacing(getResources().getDimensionPixelSize(R.dimen.min_horizontal_spacing))

.typeface(Typeface.createFromAsset(getContext().getAssets(), "RobotoSlab-Regular.ttf"))

.chipListener(new ChipListener() {

@Override

public void chipSelected(int index) {

//...

}

@Override

public void chipDeselected(int index) {

//...

}

})

.build();

Default value of textSize is equivalent to 13sp, of verticalSpacing is equivalent to 8dp, of minHorizontalSpacing is equivalent to 8dp, of allCaps is false.

All chips have a height of 32dp and a padding of 12dp on left and right within the chip, as per material guidelines.

Add items dynamically too:

chipCloud.addChip("Foo");

chipCloud.addChip("Bar");

//or

chipCloud.addChips(someStringArray);

Set the selected index using chipCloud.setSelectedChip(2)

Real-world example for shoe sizes:

1f5de8c8710c4b1eda837af273fd4aa4.png

Labels can also be updated in-place, e.g.

from e496b6e03a8ae67ae3985b78e513d89a.png to a05151b4bfa568f0199abdbd48e9ebc2.png

using update() as illustrated below

new ChipCloud.Configure().chipCloud(binding.chipCloud).labels(newChipLabels).update();

Modes

public enum Mode {

SINGLE, MULTI, REQUIRED, NONE

}

The default mode is single choice (where it's valid to have no chip selected), if you want a RadioGroup manadatory style where once a chip is selected there must always be a selected item use chipCloud.setMode(ChipCloud.Mode.REQUIRED); (or set in xml or the builder). There's a multiple select mode too: chipCloud.setMode(ChipCloud.Mode.MULTIPLE);. If you want to deactiviate selecting of chips you can set the select mode to chipCloud.setMode(ChipCloud.Mode.NONE);.

Gravity

public enum Gravity {

LEFT, RIGHT, CENTER, STAGGERED

}

The default gravity is LEFT. CENTER and STAGGERED are similar except that CENTER leaves only minimum horizontal spacing between the chips whereas in STAGGERED chips occupy the available space equally while having at least minimum horizontal spacing between them.

5389875c8d9c5e5e4026d5a2dd708a21.png

0703bafe40b1dc1caffe12d1aad889a5.png

8f70ba62a1a71491ef5831fa861c3b0c.png

50978751bc61c039bbd6f84de37a34b2.png

LEFT

RIGHT

CENTER

STAGGERED

Dependency

Add jitpack.io to your root build.gradle, eg:

allprojects {

repositories {

jcenter()

maven { url "https://jitpack.io" }

}

}

then add the dependency to your project build.gradle:

dependencies {

compile fileTree(dir: 'libs', include: ['*.jar'])

compile 'com.github.adroitandroid:ChipCloud:2.2.1'

}

You can find the latest version in the releases tab above: https://github.com/adroitandroid/ChipCloud/releases

Licence

In short:

The MIT License is a permissive license that is short and to the point. It lets people do anything they want with your code as long as they provide attribution back to you and don’t hold you liable.

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看REAdMe.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READme.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 、 1资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READmE.文件(md如有),本项目仅用作交流学习参考,请切勿用于商业用途。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。
1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通;、本 3项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看ReadmE.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 、资 1源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看READMe.m文件(如d有),本项目仅用作交流学习参考,请切勿用于商业用途。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值