[英]Spinner background is not correct on Android 6.0+
I use Android project(old project) on Eclipse. 我在Eclipse上使用Android项目(旧项目)。
I install ADT from here: 我从这里安装ADT:
https://dl-ssl.google.com/android/eclipse/
In my manifest.xml 在我的manifest.xml中
<uses-sdk
android:minSdkVersion="15"
android:targetSdkVersion="15" />
snippet of xml layout: xml布局片段:
<Spinner
android:id="@+id/currencySpinner"
style="@style/racommon_spinner_custom_style"
android:layout_width="0dip"
android:layout_height="40dip"
android:layout_weight="0.3"
android:prompt="@string/currency" />
here styles.xml 这里是styles.xml
<style name="racommon_spinner_custom_style" parent="@android:style/Widget.Holo.Light.Spinner">
<item name="android:background">@drawable/racommon_spinner_custom_bg</item>
<item name="android:clickable">true</item>
</style>
Here drawable racommon_spinner_custom_bg : 这里是drawable racommon_spinner_custom_bg :
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/spinner_selected_custom_border"/>
<item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/spinner_pressed_custom"/>
<item android:drawable="@drawable/spinner_default_custom" />
</selector>
here res\\drawable-mdpi\\spinner_pressed_custom.9.png
这里
res\\drawable-mdpi\\spinner_pressed_custom.9.png
Here result on Android 4.3 这是Android 4.3的结果
and here result on Android 6.0+ 这里的结果是Android 6.0+
Here when click on spinner: 点击微调器时:
As you can see the background of spinner is different than on Android 4.0. 正如您所看到的,微调器的背景与Android 4.0不同。 On android 4.0.
在Android 4.0上。 is correct spinner's background.
是正确的微调器的背景。 But in android 6.0+ not correct.
但在android 6.0+中不正确。
Here result nine-pathch generator 这里结果九路发电机
Why? 为什么?
Since you aren't setting gradient background programmatically, the problem is just with the style used from deprecated theme: Widget.Holo.Light.Spinner
. 由于您没有以编程方式设置渐变背景,因此问题仅在于弃用主题使用的样式:
Widget.Holo.Light.Spinner
。
Just replace it with up to date theme like Widget.AppCompat.Light.Spinner
. 只需将其替换为最新的主题,如
Widget.AppCompat.Light.Spinner
。
Also you can try just to update targetSdkVersion
and use more recent SDK version if that's an option for you. 此外,您可以尝试更新
targetSdkVersion
并使用更新的SDK版本(如果这是您的选项)。
Some clarification: the actual cause of the gradients to be broken on newer Android versions is the new requirement to specify values in dp, see Android Gradient on Lollipop not working. 一些澄清:在较新的Android版本上打破渐变的实际原因是在dp中指定值的新要求,请参阅Lollipop上的Android Gradient无法正常工作。 - API 21
- API 21
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.