开发者

Default Eclipse Theme for Android Development Spinners?

开发者 https://www.devze.com 2023-03-11 02:19 出处:网络
The color of my Spinner widgets change from phone to phone based on there settings,I would like to keep them the same between all phones开发者_开发问答 and I would like to have it be the default eclip

The color of my Spinner widgets change from phone to phone based on there settings,I would like to keep them the same between all phones开发者_开发问答 and I would like to have it be the default eclipse uses in its emulators the color is silverish. Can you please let me know how to apply this specific theme to my Spinner in xml. Thanks in advance.


download the images used in for the spinner from the android source code: spinner_press.9.png, spinner_select.9.png, spinner_normal.9.png then create selector using those. this is the default selector:

    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
          android:drawable="@drawable/spinner_press" />
    <item android:state_pressed="false" android:state_focused="true"
          android:drawable="@drawable/spinner_select" />
    <item android:drawable="@drawable/spinner_normal" />
</selector>


You don't need to create a theme. Just apply a background of your choice to the spinner, as with any other View.

If you want to have different backgrounds you can use a (See here for more info)

For an example of an implementation, nothing better than the android source: https://android.googlesource.com/platform/frameworks/base/+/froyo-release/core/res/res/drawable/spinner_background.xml

You can get the actual 9-patch files from there also (and choose which version you would like to use).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号