I was wanting to know if there is a selector for layouts like there is for drawables.
Example of selector with drawable:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected -->
<item android:drawable="@drawable/tab_library_clicked"
android:state_selected="true" />
<!-- When not selected -->
<item android:drawable="@drawable/tab_library_not_clicked" />
But is it possible to have something like this (This code below didn't work for me but it should give you an idea of what I am trying to accomplish):
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- When selected -->
<item android:layout="@layout/tab_library_clicked"
android:state_selected="true" />
<!-- When not selected -->
<item android:layout="@layout/tab_library_not_clicked" />
I might be wrong, but I'm pretty sure this doesn't exist.
The most "sophisticated" you'll be able to do with a selector in XML probably is using a drawable layer list to combine several drawables onto one state.
Alternatively you can try using the touch_down and touch_up events to programmatically call setVisibility()
on the layouts, but I imagine the performance will be very poor.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With