【问题标题】:Android 7 is not showing layer-list xml drawable?Android 7 不显示图层列表 xml 可绘制?
【发布时间】:2016-12-06 13:05:24
【问题描述】:

我有以下形状:

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

它看起来像这样:

这是我将它添加到 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"/>

环形显示在我拥有的所有设备上,Samsung A5、A3、S4 mini、S3 从 Android 4.4 到 Android 5+,但今天我得到了一个带有 Android 7 的 Lg Nexus 5x,当我运行该应用程序时, xml 图像不显示。

我找到了一种显示它的方法,但这意味着我必须对它的宽度和高度进行硬编码,而我不想那样做。这里似乎有什么问题?手机,安卓版本,代码?任何建议都会很棒。谢谢!

【问题讨论】:

  • “我必须硬编码它的宽度和高度,我不想那样做”——你的 ImageView 已经硬编码了宽度和高度。
  • 是的,没错,这就是我在屏幕上看到图像的方式
  • 那么您可能希望编辑您的问题以显示不起作用的代码。
  • 好的,我已经编辑了代码,现在这个表格不起作用
  • 如果我这样做,戒指就会永远消失。我认为这个问题与 android 7 有关。

标签: android xml android-imageview android-xml android-7.0-nougat


【解决方案1】:

似乎我无法弄清楚“环”xml 代码的问题是什么,但我找到了另一种绘制环的方法。

我不知道问题是否来自 Android 7。

所以对于那些有同样问题的人来说,这里有一个戒指的解决方案。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-08-10
    相关资源
    最近更新 更多