Java Android spinner风格不变
因此,我让微调器工作正常,但除了activity_main.xml中的背景色之外,我无法更改任何样式 第一个是简单的\u微调器\u下拉列表\u item.xmlJava Android spinner风格不变,java,android,xml,Java,Android,Xml,因此,我让微调器工作正常,但除了activity_main.xml中的背景色之外,我无法更改任何样式 第一个是简单的\u微调器\u下拉列表\u item.xml <TextView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/text1" style="?android:attr/spinnerDropDownItemStyle"
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/app_primary"
android:ellipsize="marquee"
android:layout_centerVertical="true"
android:singleLine="true"
android:textColor="@color/white"
/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:background="@color/app_primary"
android:textSize="20sp"
android:textStyle="normal"
/>
第二个是simple_dropdown_item.xml
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="@color/app_primary"
android:ellipsize="marquee"
android:layout_centerVertical="true"
android:singleLine="true"
android:textColor="@color/white"
/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:background="@color/app_primary"
android:textSize="20sp"
android:textStyle="normal"
/>
如果要自定义下拉列表项,需要创建新的布局文件。我们将其命名为spinner\u dropdown\u item.xml:
<?xml version="1.0" encoding="utf-8"?>
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="?android:attr/listPreferredItemHeight"
android:ellipsize="marquee"
android:textColor="#aa66cc"/>
试试这个,希望对你有所帮助你到底想做什么?你能说得更具体些吗?先改变背景颜色和文本颜色。你不改变这些属性吗?
android:textColor=“@color/white”
,android:background=“@color/app\u primary”
,以达到你想要的效果?我试过了,但似乎不起作用,我不知道为什么。我可以在这里更改活动主界面中的
,但它只会更改背景颜色。您可以在为微调器添加适配器的位置添加活动代码吗?