在我的项目中,此自定义布局在操作栏中已膨胀:
但我想使用白色的微调框文字。我在网上看到了很多与此相关的主题,但是我还不能解决问题。我该如何解决这个问题?如何通过将微调器的文本颜色设置为白色来更改它的颜色?
编辑:微调器的xml代码是这样的:
<Spinner
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="#ffffff"
android:id="@+id/spinner"></Spinner>
这很简单,我尝试了很多事情,但是什么也没做。
在您的活动中,您应该具有以下内容:(基本上,您正在获取Spinner并将其设置为适配器。此适配器负责填充它)
Spinner spinner = (Spinner) findViewById(R.id.your_spinner_id);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), R.layout.your_selected_spinner_item, myArrayList<String));
adapter.setDropDownViewResource(R.layout.your_dropdown_item);
spinner.setAdapter(adapter);
您可以使用以下XML :(将它们放在res / layout上)
your_selected_spinner_item.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myLayoutID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textSize="20sp"/>
还有your_dropdown_item.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myDropdownLayoutID"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:textSize="20sp"/>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句