简体   繁体   English

Android 7不显示可绘制的图层列表XML?

[英]Android 7 is not showing layer-list xml drawable?

I have the following shape: 我有以下形状:

<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
    android:top="9dp"
    android:right="9dp"
    android:bottom="9dp"
    android:left="9dp">
    <shape
        android:shape="oval">
        <solid android:color="#4d4d4d" />
    </shape>
</item>
<item>
    <shape
        android:shape="oval">
        <stroke android:width="2dp"
            android:color="#4d4d4d"/>
    </shape>
</item>

And it looks like this: 它看起来像这样: 在此处输入图片说明

And here is how I add it to the ImageView: 这是我将其添加到ImageView的方法:

<ImageView
        android:id="@+id/couterImage"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_centerInParent="true"
        android:baselineAlignBottom="false"
        android:background="@drawable/ring_selector"/>

The ring shape isdisplayed on all devices that I have, Samsung A5, A3, S4 mini, S3 from Android 4.4 to andtoid 5+, but today I got an Lg Nexus 5x with Android 7 and when I run the app, the xml image is not displayed. 环形显示在我拥有的所有设备上,从Android 4.4到andtoid 5+的三星A5,A3,S4 mini,S3,但是今天我得到了带有Android 7的Lg Nexus 5x,当我运行该应用程序时,xml图像是不显示。

I found a way to display it but that means that I have to hardcode it's width and height and I dont want that. 我找到了一种显示它的方法,但这意味着我必须对它的宽度和高度进行硬编码,而我不希望这样。 What seems to be the problem here? 这里似乎是什么问题? the phone, android version,the code? 手机,Android版本,代码? Any suggestions would be awesome. 任何建议都很棒。 Thanks! 谢谢!

It seems that i cannot figure out what was the problem for the "ring" xml code, but I found another way to draw the ring. 似乎我无法弄清楚“ ring” xml代码出了什么问题,但是我找到了另一种绘制圆环的方法。

I dont know if the problem is from Android 7 or not. 我不知道问题是否出在Android 7上。

So for those who have the same problem, here is a solution for the ring. 因此,对于那些有相同问题的人,这里有解决方案。

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<stroke
    android:width="2dp"
    android:color="#4d4d4d" />
<size
    android:width="17dp"
    android:height="17dp" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM