chip-navigation-bar icon indicating copy to clipboard operation
chip-navigation-bar copied to clipboard

Icon animation "state_checked"=true/false not working

Open AsitDixit opened this issue 3 years ago • 1 comments

Just like material bottom navigation bar I want to achieve something like: When icon selected : filled icon When icon not selected : Outlined icon

IN PLACE OF MENU ITEMS ICON I'M USING BELOW XML FILE :

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/homeoutline" android:state_checked="false"/>
    <item android:drawable="@drawable/homefilled" android:state_checked="true"/>
</selector>

But this is not working I'm getting outlined icon every time whether icon selected or not selected. Please help.

AsitDixit avatar Sep 16 '22 13:09 AsitDixit

Just like material bottom navigation bar I want to achieve something like: When icon selected : filled icon When icon not selected : Outlined icon

IN PLACE OF MENU ITEMS ICON I'M USING BELOW XML FILE :

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/homeoutline" android:state_checked="false"/>
    <item android:drawable="@drawable/homefilled" android:state_checked="true"/>
</selector>

But this is not working I'm getting outlined icon every time whether icon selected or not selected. Please help.

try android:state_selected not android:state_checked

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/homeoutline" android:state_selected="false"/>
    <item android:drawable="@drawable/homefilled" android:state_selected="true"/>
</selector>

enesarisoy avatar Apr 03 '24 16:04 enesarisoy