简体   繁体   English

我的微调小部件在不同的设备上看起来有所不同。 如何定义在所有手机上看起来都一样的Spinner?

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

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. 在我的设备(Motorola Milestone)和仿真器上,这看起来像标准的灰色微调小部件。 On of my colleagues uses a Motorola Backflip and on his device the Spinner is black. 在我的同事中,使用Motorola Backflip,在他的设备上,微调器是黑色的。 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. 我不介意在所有设备上都使用灰色微调器,但在所有设备上看起来应该始终相同。

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). 这就是我坚持使用Nexus One作为我的私人电话的确切原因(避免运营商和制造商在其电话中添加“价值”)。

Anyway, you can actually go and copy the resources from the the SDK into your own project and use the progress bar from there. 无论如何,您实际上可以去将SDK中的资源复制到您自己的项目中,并从那里使用进度条。 The directory is here: \\android-sdk-windows\\platforms\\android-2.1\\data\\res. 该目录位于:\\ android-sdk-windows \\ platforms \\ android-2.1 \\ data \\ res。 You'll also have to copy the animation drawable called something like "progress_large.xml": 您还必须复制称为“ 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. 但是想法是一样的:在同一目录中有一个“ spinner_background.xml”和相关的图形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM