kartoos khan
kartoos khan

Reputation: 449

Change android chip icon position

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.

Upvotes: 0

Views: 3854

Answers (4)

moonLander_
moonLander_

Reputation: 86

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

Upvotes: 0

Parth Desai
Parth Desai

Reputation: 196

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
}

Upvotes: 0

Codemaker2015
Codemaker2015

Reputation: 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

Upvotes: 0

junaidirshad098
junaidirshad098

Reputation: 49

use this property to change chip icon position:

android:layoutDirection="rtl"

Upvotes: 1

Related Questions