我在一个片段中有一个微调器,它有一个非常烦人的图形故障。这只发生在我的带有 API 21 的 Nexus 5 上。
我尝试设置 spinner.setLayerType(View.LAYER_TYPE_SOFTWARE, null) 但故障仍然存在。有任何想法吗?
我在一个片段中有一个微调器,它有一个非常烦人的图形故障。这只发生在我的带有 API 21 的 Nexus 5 上。
我尝试设置 spinner.setLayerType(View.LAYER_TYPE_SOFTWARE, null) 但故障仍然存在。有任何想法吗?
我设法以两种不同的方式解决了这个错误:
为您的微调器设置样式:
<Spinner
android:background="@drawable/background"
android:id="@+id/spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@android:style/Widget.Holo.Light.Spinner"/>
也许预定义样式中的背景颜色对您来说已经足够了。如果不试试
创建一个具有圆角半径的可绘制形状:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="2dp" />
<solid android:color="#00ff00" />
</shape>
并将其设置为您的微调器的弹出背景
<Spinner
android:background="@drawable/spinner_background"
android:id="@+id/date_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:popupBackground="@drawable/spinner_popup_background"/>
希望这会有所帮助!