I want a simple TextView
to behave the way simple_list_item_1
in a ListView
does. Here's the XML:
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:gravity="center" android:focusable="true"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="@android:drawable/list_selector_background" />
Everything works except for the text color that (expectedly) doesn't change in focused state. How do I make it change to textAppearanceLargeInverse
?
Here's my implementation, which behaves exactly as item in list (at least on 2.3)
res/layout/list_video_footer.xml
res/color/bright_text_dark_focused.xml
I always used the above solution without searching more after this. ;-)
However, today I came across something and thought of sharing it. :)
This feature is indeed available from API 1 and is called as ColorStateList, where we can supply a color to various states of Widgets (as we already know).
It is also very well documented, here.