0
我一直在試圖添加一個微調器到我的工具欄,但未能實現我想要的。帶有微調的白色文本和白色彈出背景的Android工具欄?
這是我到目前爲止。
正如你可以在屏幕截圖看到,Spinner的選擇的文本顏色爲黑色(我希望它是白色的),而彈出有一個白色的背景,文字顏色黑色(這是確定)。
這裏是我的代碼。
<android.support.v7.widget.Toolbar
android:id="@+id/bottom_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:layout_alignParentBottom="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_date_range_white_24dp" />
<android.support.v7.widget.AppCompatSpinner
android:id="@+id/date_range"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:entries="@array/date_range_options"
android:spinnerMode="dropdown" />
</LinearLayout>
</android.support.v7.widget.Toolbar>
如果我改變工具欄,並添加應用程序:主題=「@風格/ ThemeOverlay.AppCompat.Dark.ActionBar」象下面這樣:
<android.support.v7.widget.Toolbar
android:id="@+id/bottom_toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:layout_alignParentBottom="true">
我獲得選擇的紡紗的白色文本文本,但彈出式背景也會變成黑色,同時還會顯示白色文字。
我想要在選定的文本顏色和帶有黑色文本的白色彈出背景。
我該怎麼做?
嗨。我試過你的建議,但沒有奏效。它顯示的效果與上面屏幕截圖中的效果相同。 – ank
奇怪也許是因爲它在工具欄中。這奇怪地適合我。您是否使用微調器的自定義適配器?如果是這樣的getView方法,你可以做這個TextView textView =(TextView)convertView.findViewById(android.R.id.text1); deviceName.setTextColor(ContextCompat.getColor(getContext(),R.color.white_text)); 這是假設你正在使用微調器的默認佈局(android.R.layout.simple_list_item_1) – Ben
不,我沒有使用適配器。這全部在xml上。 – ank