无法在某些设备上正确显示Android的XML层列表 [英] Android xml layer-list not displayed correctly on some devices
问题描述
我有一个XML图层列表绘制作为视图的背景下,这是不是在某些设备上显示correctl。
我有4.2.2华为登高伴侣这显示它确定。
在4.1.2华硕平板电脑phonepad我看到的只是该项形状笔划和没有看到其他项目。
我在做什么错了?
<?XML版本=1.0编码=UTF-8&GT?;
<层列表的xmlns:机器人=http://schemas.android.com/apk/res/android> <项目>
<形状机器人:形状=矩形>
[固体机器人:色=@色/ yellow_color/>
< /形状>
< /项目>
<项目>
<位图
机器人:重力=CENTER_HORIZONTAL |底
机器人:SRC =@绘制/ dotted_bg
机器人:TILEMODE =重复/>
< /项目>
<项目>
<形状和GT;
<中风
机器人:宽=4DP
机器人:颜色=@色/ yellow_color/>
< /形状>
< /项目>
<项目>
<位图
机器人:重力=CENTER_HORIZONTAL |底
机器人:SRC =@绘制/ tls_bg/>
< /项目>< /层列表>
我已经解决了该问题。显然,在某些设备(Android 4.0及4.1.1)以下的code下面做如下形状的所有层与黑色上述磨削。
<项目>
<形状和GT;
<中风
机器人:宽=4DP
机器人:颜色=@色/ yellow_color/>
< /形状>
< /项目>
我已经加入透明的纯色造型,现在它工作正常。
<项目>
<形状和GT;
<中风
机器人:宽=4DP
机器人:颜色=@色/ yellow_color/>
[固体机器人:色=@机器人:彩色/透明/>
< /形状>
< /项目>
所以永远不要离开边境的形状没有颜色一些设备将它涂黑!
I have an xml layer list drawable as a background for view, which is not displayed correctl on some devices.
I have a Huawei Ascend Mate with 4.2.2 which displays it ok. On Asus phonepad tablet with 4.1.2 i see just the item shape stroke and dont see the other items.
What am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<shape android:shape="rectangle" >
<solid android:color="@color/yellow_color" />
</shape>
</item>
<item>
<bitmap
android:gravity="center_horizontal|bottom"
android:src="@drawable/dotted_bg"
android:tileMode="repeat" />
</item>
<item>
<shape>
<stroke
android:width="4dp"
android:color="@color/yellow_color" />
</shape>
</item>
<item>
<bitmap
android:gravity="center_horizontal|bottom"
android:src="@drawable/tls_bg" />
</item>
</layer-list>
I've fixed the issue. Apparently on some devices (android 4.0 and 4.1.1) the following code made all layers below the following shape to be overpainted with black color.
<item>
<shape>
<stroke
android:width="4dp"
android:color="@color/yellow_color" />
</shape>
</item>
I have added transparent solid color for the shape and now it works fine.
<item>
<shape>
<stroke
android:width="4dp"
android:color="@color/yellow_color" />
<solid android:color="@android:color/transparent" />
</shape>
</item>
So never leave shapes with border without color as some devices will paint it black!
这篇关于无法在某些设备上正确显示Android的XML层列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!