My Spinner Widgets look different on different devices. How can I define a own Spinner that looks the same on all handsets?

好久不见. 提交于 2019-12-25 05:48:09

问题


I use this code to generate a spinner in my app:

    subCatAdapter = new ArrayAdapter<Subcategory>(this, android.R.layout.simple_spinner_item, subCategories);
    subCatAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

On my device (Motorola Milestone) and in the emulator this looks like the standard gray spinner widget. On of my colleagues uses a Motorola Backflip and on his device the Spinner is black. Now its very hard to read the font in the spinner.

What do I have to do to use my own view for the spinner? I don't mind to have the gray spinner on all devices, but it should always look the same on all devices.


回答1:


This is the exact reason why I'll stick with the Nexus One as my personal phone (avoiding the "value" that carriers and manufacturers add to their phones).

Anyway, you can actually go and copy the resources from the the SDK into your own project and use the progress bar from there. The directory is here: \android-sdk-windows\platforms\android-2.1\data\res. You'll also have to copy the animation drawable called something like "progress_large.xml":

<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/spinner_black_76"
    android:pivotX="50%"
    android:pivotY="50%"
    android:framesCount="12"
    android:frameDuration="100" />

Edit: Sorry, just realized you meant "spinner" not the "spinning progress bar". The idea is the same though: there's a "spinner_background.xml" and associated graphics in the same directory.



来源:https://stackoverflow.com/questions/2874310/my-spinner-widgets-look-different-on-different-devices-how-can-i-define-a-own-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!