问题描述
我有一个片段,它有一个非常恼人的图形毛刺1微调。只是这发生在我的Nexus 5与API 21。
I have one spinner in a fragment that have a very annoying graphical glitch.This occurs only on my Nexus 5 with API 21.
我已经尝试设置spinner.setLayerType(View.LAYER_TYPE_SOFTWARE,空),但故障依旧present。任何想法?
I have try to set spinner.setLayerType(View.LAYER_TYPE_SOFTWARE, null) but the glitch is still present.Any ideas?
推荐答案
我设法解决这个错误,在两种不同的方式:
I managed to work around this bug in two different ways:
-
设置样式为您的微调:
Set a style to your spinner:
<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"/>
也许在predefined风格的背景颜色是够你。如果没有尝试
maybe the background color in the predefined styles is enough for you. If not try
创建一个形状绘制一个圆角半径:
Create a shape drawable with a corner radius:
<?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>
,并将其设置为popupBackground到您的微调
and set it as a popupBackground to your spinner
<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"/>
希望这是有帮助的!
hope this is helpful!
这篇关于微调图形错误API 21的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!