gpt4 book ai didi

android - 在多行中并排显示博客样式标签 (Android)

转载 作者:行者123 更新时间:2023-11-29 00:06:18 33 4
gpt4 key购买 nike

请看下图: Multiple Tags appearing side by side

我想在 Android 应用中并排显示一组标签。条件是:

  • 每个标签都显示在前一个标签的旁边。
  • 如果水平空间用完,下一个标签将出现在新行中。
  • 如果标签中有多个词,而标签中的某些词只有一个空格,则将整个标签移到新行中。但是,如果标签已经在一个新行中,让标签分成两行。

我不确定这种技术叫什么。将不胜感激任何有关此问题的帮助,无论是通过代码还是链接到库。

最佳答案

您可以为标签使用简单的库,例如:

AndroidTagGroup

添加到您的 xml:

<me.gujun.android.taggroup.TagGroup
android:id="@+id/tag_group"
style="@style/TagGroup" />

并添加代码:

TagGroup mTagGroup = (TagGroup) findViewById(R.id.tag_group);
mTagGroup.setTags(new String[]{"Tag1", "Tag2", "Tag3"});

另一个解决方案是:

AutoLabelUI

添加到 xml:

<com.dpizarro.autolabel.library.AutoLabelUI
android:id="@+id/label_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>

并添加到代码中:

AutoLabelUI mAutoLabel = (AutoLabelUI) view.findViewById(R.id.label_view);

AutoLabelUISettings autoLabelUISettings = new AutoLabelUISettings.Builder()
.withMaxLabels(5)
.withIconCross(R.drawable.cross)
.withBackgroundResource(android.R.color.holo_blue_bright)
.withLabelsClickables(false)
.withShowCross(true)
.withTextColor(android.R.color.holo_red_dark)
.withTextSize(R.dimen.label_title_size)
.build();

mAutoLabel.setSettings(autoLabelUISettings);

此外,您可以使用 HashtagView

关于android - 在多行中并排显示博客样式标签 (Android),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33569754/

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