Different styles depending on the state of the buttons? - Android

I have many custom buttons (ToggleButton) in my application and you want to apply different styles for each button. I have created a selector for all buttons, and currently I am only changing the button to select, for example:

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

When I try to change the style in the same way:

 <item android:state_checked="true" android:drawable="@drawable/button_gradient_selected" style="@style/button_checked /> 

This will not work, I tried to change the style in the style instead (and just specified the style in the selector), I also tried to create a separate selector, but nothing works.

Any ideas?

+4
source share
1 answer

Now it is impossible to do.

0
source

Source: https://habr.com/ru/post/1340588/


All Articles