The solution is to use the built-in Android resource selection system. You must specify two different styles and place them in the appropriate folders based on the version of the API. Please note that the following examples are not mine, I took them from this tutorial.
res/values-v4/styles.xml :
<resources> <style name="MyListTextAppearanceSmall"> <item name="android:textAppearance">?android:attr/textAppearanceSmallInverse</item> </style> <style name="MyListTextAppearanceDefault"> <item name="android:textAppearance">?android:attr/textAppearanceInverse</item> </style> <style name="MyListTextAppearanceMedium"> <item name="android:textAppearance">?android:attr/textAppearanceMediumInverse</item> </style> </resources>
res/values-v11/styles.xml :
<resources> <style name="MyListTextAppearanceSmall"> <item name="android:textAppearance">?android:attr/textAppearanceSmall</item> </style> <style name="MyListTextAppearanceDefault"> <item name="android:textAppearance">?android:attr/textAppearance</item> </style> <style name="MyListTextAppearanceMedium"> <item name="android:textAppearance">?android:attr/textAppearanceMedium</item> </style> </resources>
Then in the TextView specify the style:
<TextView android:style="@style/MyListTextAppearanceSmall" android:id="@+id/label" android:layout_width="fill_parent" android:layout_height="wrap_content" android:singleLine="true" android:ellipsize="marquee" />
See the tutorial above for a more detailed explanation.
howettl
source share