如何制作下图中类似 Zomato 的类别选择器

How to make category selector like Zomato in the image below

是否有任何 github 库,如果有,你能帮我吗?如果没有,其他解决方案是什么

我想要和"Home work other buttons"

一样的东西

谢谢

您可以使用 Material 组件中的 Chips 组件。

您图片中使用的 Chip 是一个选择筹码,可以这样使用:

<com.google.android.material.chip.Chip
    style="@style/Widget.MaterialComponents.Chip.Choice"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Home"/>

是的,你可以通过 Chips

使用MaterialComponents

https://material.io/develop/android/components/chip/

implementation 'com.google.android.material:material:1.2.0-alpha03'

并使用像 ...

这样的 Materialtheme
<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
    <!-- Customize your theme here. -->
    <item name="colorPrimary">@color/colorPrimary</item>
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
    <item name="colorAccent">@color/colorAccent</item>
</style>

您的 xml 布局文件

<com.google.android.material.chip.ChipGroup
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

  <!-- Chips can be declared here, or added dynamically. -->

</com.google.android.material.chip.ChipGroup>