问题描述:

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

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.

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? 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.

I dont know if the problem is from Android 7 or not.

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" />

相关阅读:
Top