如何更改微调器的文本颜色
答
试试这个
custom_spinner_item.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top"
android:singleLine="true"
android:textColor="@color/iphone_text" />
在Java代码中
Spinner spnCategory= (Spinner)findViewById(R.id.my_spinner);
..
ArrayAdapter<String> adptSpnCategory = new ArrayAdapter<String>this,R.layout.custom_spinner_item, alCategoryName);
adptSpnCategory.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spnCategory.setAdapter(adptSpnCategory);
spnCategory.setOnItemSelectedListener(new OnItemSelectedListener()
{
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3)
{
}
public void onNothingSelected(AdapterView<?> arg0)
{
}
});
+0
但它也增加了微调的大小。在我的情况下,我做透明的微调视图,并将其放在更近的地方。所以如果按照上面提到的那样影响微调对话框和微调视图的大小以及...任何其他建议? – CoDe 2014-07-15 13:11:06
答
试试这个:
Spinner spinner = (Spinner)findViewById(R.id.my_spinner);
TextView tv = (TextView) spinner.getSelectedView();
tv.setTextColor(Color.BLACK);
在spinner_xml以其他方式改变:
<?xml version="1.0" encoding="utf-8"?>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="20dip"
android:gravity="left"
android:textColor="#FF0000"
android:padding="5dip"
/>
+1
要小心,getSelectedView()应该在选择项目后调用。 – usman 2014-03-07 06:57:03
请通过链接 http://stackoverflow.com/questions/9476665/how-to-change-spinner-text-size- and-text-color – 2013-02-12 13:35:54
主题如何控制spinner样式在这里解释:http://tekeye.biz/2012/changing-android-spinner-text-size – 2013-02-13 00:43:11