0

I have added a few chips in my app. The default chip have tick icon when you select it like this. enter image description here

I want to change the icon position to the bottom. Like this. enter image description here

There is no property to change the icon position. How can I achieve this result.

kartoos khan
  • 409
  • 6
  • 22
  • Is it mandatory to use material chips to achieve these kind of UI results? I think you can do it in any other ways. – A S M Sayem Oct 22 '19 at 17:29
  • Yes I achieved this result with the help of layer-list but wanted to do it with the help of chips – kartoos khan Oct 22 '19 at 17:42
  • You can't do it with a Chip.You can use an iconStart or an iconEnd. – Gabriele Mariotti Oct 22 '19 at 17:57
  • Okay then use custom layout for your chip view, and inflate it when you are adding your chip. Use layer-list background to which one is selected or not. Will these procedure serve your purposes?@kartooskhan – A S M Sayem Oct 22 '19 at 18:04

4 Answers4

0

use this property to change chip icon position:

android:layoutDirection="rtl"
Elikill58
  • 4,050
  • 24
  • 23
  • 45
0

Start icon

app:chipIconVisible — visibility of the chip icon. app:chipIcon — drawable icon to show at the start of the chip. app:chipIconSize — size of the chip icon.

chip.setOnClickListener {
   // Handle chip click
}

close icon

app:closeIconVisible — visibility of the close icon. app:closeIcon — drawable icon show at end of the chip. app:closeIconSize — size of the close icon.

chip.setOnCloseIconClickListener {
    // Handle chip close icon click
}
Parth Desai
  • 196
  • 2
  • 10
0

You can utilize the closeIcon properties since it already on the right side of the chip. something like this:

 <com.google.android.material.chip.Chip
        android:id="@+id/customerListChipSort"
        style="@style/MyChip"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Sort"
        android:textStyle="bold"
        app:closeIcon="@drawable/ic_dropdown"
        app:closeIconEnabled="true"
        app:closeIconSize="@dimen/dimens_12dp"
        app:closeIconTint="@color/observatory_green" />

and the results is this: sort button

-1

You could set android:layoutDirection="rtl" or the opposite of your current direction to put the icon on the right.

For more: https://material.io/design/usability/bidirectionality.html

Codemaker2015
  • 12,190
  • 6
  • 97
  • 81