gpt4 book ai didi

Android UI控件类标签控件

转载 作者:太空狗 更新时间:2023-10-29 12:42:12 25 4
gpt4 key购买 nike

我想知道如何获得包含如下图所示排列的字符串列表的控件。

enter image description here

可以看到根据宽度随机添加的字符串

我尝试在线性或相对布局中使用普通 TextView ,但它没有用。你能告诉我最好的做法是让一个控件传递给它一个字符串列表并像下面的图像那样显示它们吗?

最佳答案

这可以使用流式布局和其中的切换按钮来完成。提供良好的流式布局here .并且切换按钮将需要一个 Selector 可绘制对象来为其提供正确的选中/未选中外观。

这是一个选择器示例:

<?xml version="1.0" encoding="utf-8"?>

<item android:drawable="@drawable/rect_tag_checked" android:state_checked="true"></item>
<item android:drawable="@drawable/rect_tag_normal" android:state_checked="false"></item>
<item android:drawable="@drawable/rect_tag_normal"></item>

关于Android UI控件类标签控件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23946710/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com