Filter With Chips Android
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
Solution 1:
It is not exactly what you are looking for but you can use:
- a container with rounded corners, like a
CardViewor aLinearLayout - single
Buttonwith rounded corners for each items - add animations on the
onClickevent
Something like:
<LinearLayoutandroid:id="@+id/ll_container"..><com.google.android.material.button.MaterialButtonstyle="@style/materialButtonOutlinedStyle".../><Viewandroid:layout_width="1dp"android:layout_height="..."../><com.google.android.material.button.MaterialButtonstyle="@style/materialButtonOutlinedStyle"..><!-- ..... --></LinearLayout>with:
<stylename="materialButtonOutlinedStyle"parent="Widget.MaterialComponents.Button.TextButton"><itemname="strokeWidth">0dp</item><itemname="shapeAppearanceOverlay">@style/rounded_button</item><itemname="android:insetTop">0dp</item><itemname="android:insetBottom">0dp</item></style><stylename="rounded_button"><itemname="cornerFamily">rounded</item><itemname="cornerSize">50%</item></style>For the container you can wrap the buttons with a CardView with rounded corners or you can simply apply to a LinearLayout something like:
floatradius= getResources().getDimension(R.dimen.default_corner_radius);
LinearLayout linearLayout= findViewById(R.id.ll_container);
ShapeAppearanceModelshapeAppearanceModel=newShapeAppearanceModel()
.toBuilder()
.setAllCorners(CornerFamily.ROUNDED,radius)
.build();
MaterialShapeDrawableshapeDrawable=newMaterialShapeDrawable(shapeAppearanceModel);
shapeDrawable.setFillColor(ContextCompat.getColorStateList(this,R.color.white));
shapeDrawable.setStrokeWidth(1.0f);
shapeDrawable.setStrokeColor(ContextCompat.getColorStateList(this,R.color...));
ViewCompat.setBackground(linearLayout,shapeDrawable);


Post a Comment for "Filter With Chips Android"