用芯片过滤android [英] Filter with chips android

查看:79
本文介绍了用芯片过滤android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想问你是否存在于一个单选按钮的组件中,但是它是像这种图像一样从芯片中格式化的.它是您要搜索游戏时Google Play游戏中提供的组件

I would like to ask you if exist in component which is an radiobutton, but it is format from chips like this image. it is an component presents in Google Play Games when you want search an game

感谢我们的回复

推荐答案

这并不是您要查找的,但是您可以使用:

It is not exactly what you are looking for but you can use:

  • 具有圆角的容器,例如 CardView LinearLayout
  • 单个 Button (每个项目带有圆角)
  • onClick 事件上添加动画
  • a container with rounded corners, like a CardView or a LinearLayout
  • single Button with rounded corners for each items
  • add animations on the onClick event

类似的东西:

   <LinearLayout
        android:id="@+id/ll_container"
        ..>

             <com.google.android.material.button.MaterialButton
                 style="@style/materialButtonOutlinedStyle"
                  .../>

              <View
                 android:layout_width="1dp"
                 android:layout_height="..."
                 ../>

              <com.google.android.material.button.MaterialButton
                  style="@style/materialButtonOutlinedStyle"
                  ..>

              <!-- ..... -->

        </LinearLayout>

具有:

  <style name="materialButtonOutlinedStyle" parent="Widget.MaterialComponents.Button.TextButton">
    <item name="strokeWidth">0dp</item>
    <item name="shapeAppearanceOverlay">@style/rounded_button</item>
    <item name="android:insetTop">0dp</item>
    <item name="android:insetBottom">0dp</item>
  </style>

  <style name="rounded_button">
    <item name="cornerFamily">rounded</item>
    <item name="cornerSize">50%</item>
  </style>

对于容器,您可以使用带有圆角的 CardView 包装按钮,也可以将其简单地应用于 LinearLayout ,例如:

For the container you can wrap the buttons with a CardView with rounded corners or you can simply apply to a LinearLayout something like:

float radius = getResources().getDimension(R.dimen.default_corner_radius);
LinearLayout linearLayout= findViewById(R.id.ll_container);
ShapeAppearanceModel shapeAppearanceModel = new ShapeAppearanceModel()
    .toBuilder()
    .setAllCorners(CornerFamily.ROUNDED,radius)
    .build();

MaterialShapeDrawable shapeDrawable = new MaterialShapeDrawable(shapeAppearanceModel);
shapeDrawable.setFillColor(ContextCompat.getColorStateList(this,R.color.white));
shapeDrawable.setStrokeWidth(1.0f);
shapeDrawable.setStrokeColor(ContextCompat.getColorStateList(this,R.color...));


ViewCompat.setBackground(linearLayout,shapeDrawable);

这篇关于用芯片过滤android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆