【发布时间】:2019-10-19 05:39:10
【问题描述】:
我的 android 应用程序已经将 popupbackground 设置为可绘制的 xml。但是,弹出对话框仍然无法显示我设置的颜色。如何解决这个问题?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".CountrySelectorActivity">
<Spinner
android:id="@+id/search_spinner1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@color/black"
android:popupBackground="@drawable/spinner_background"
android:spinnerMode="dialog"
/>
<Spinner
android:id="@+id/search_spinner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="2"
android:background="@color/black"
android:popupBackground="@drawable/spinner_background"
android:spinnerMode="dialog"/>
</LinearLayout>
@drawable/spinner_background.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="@color/green"/>
</shape>
</item>
</selector>
【问题讨论】:
-
你能添加你的android活动代码吗?构建对话框时。
-
我现在在底部添加代码链接。
标签: android background dialog spinner