如何颜色和对齐方式微调的项目在Android?颜色、方式、项目、Android

2023-09-12 07:59:28 作者:此生足矣

我尝试改变文字颜色和微调调整项目,以它的中心,我怎么能做到这一点。

I'm try to change text color and align item in spinner to center of it how can I do this

这是我的code

    String[] li={"1","2","3"};
final Spinner combo = (Spinner)findViewById(R.id.widget30);
ArrayAdapter<String> a = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, li);
combo.setAdapter(a);

感谢

推荐答案

使用该自定义视图,并通过调用指定:

Use a custom view for that, and specify by calling:

a.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

请注意,你必须在这里使用自己的看法:R.id.my_simple_spinner_dropdown_item

Note that you have to use your own view here: R.id.my_simple_spinner_dropdown_item

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@android:id/text1"
    style="?android:attr/spinnerItemStyle"
    android:singleLine="true"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:ellipsize="marquee" />