> I have a question about a tab icon. > > According to TabHost.TabSpec > > http://developer.android.com/intl/ja/reference/android/widget/TabHost.TabSpec.html > I can set only one icon for each tab with setIndicator(), but also > according to Icon Design Guidelines > > http://developer.android.com/intl/ja/guide/practices/ui_guidelines/icon_design.html#tabstructure > tab icon have two states. Can PNG image have two states?
A PNG cannot have two states, but a StateListDrawable can. You can define one of these in XML and put it in your res/drawable/ directory, referencing it as if it were a PNG or JPEG file. For example, here is a StateListDrawable for a pair of PNGs to serve as a single tab icon: <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:state_pressed="false" android:drawable="@drawable/tab1_selected" /> <item android:drawable="@drawable/tab1_normal" /> </selector> If you named this as res/drawable/tab1.xml, and also had res/drawable/tab1_selected.png and res/drawable/tab1_normal.png, you could reference this "icon" as R.drawable.tab1 in your TabSpec work, and you would get a two-state icon. -- Mark Murphy (a Commons Guy) http://commonsware.com Android App Developer Books: http://commonsware.com/books.html --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

