我的片段背景是白色的,只有在我点击它时,旋转器的箭头才会显示。
这是我的Java文件中的代码片段:
spinner = (Spinner)v.findViewById(R.id.spinner);
ArrayAdapter adapter = ArrayAdapter.createFromResource(getActivity(), R.array.accounts,R.layout.spinner_item);
adapter.setDropDownViewResource(R.layout.spinner_dropdown_items);
spinner.setAdapter(adapter);
spinner.setPrompt("Select an account");
这是我的spinner_item XML
<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="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="inherit"
android:textSize="16dp"
android:background="#FFFFFFFF"
android:textColor="#ff252525"/>
这是我为我的spinner_dropdown_items设计的布局。
<?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="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:textAlignment="inherit"
android:textSize="16dp"
android:background="#FFFFFFFF"
android:textColor="#ff252525"/>
这是我的Spinner在我的Fragment中使用白色背景的效果: 白色背景 - Spinner 当我将背景颜色改为紫色时,它的样子如下所示: 紫色背景 - Spinner
<item><bitmap..
部分更改为<item android:gravity="end" android:drawable="@drawable/drop_arrow" />
。 - Hibbem