Layer-List项目在运行时不在ImageView中显示

时间:2017-12-14 07:51:38

标签: android imageview android-drawable layer-list

我使用图层列表项来显示语音气泡:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item android:top="55dp"
          android:left="0dp"
          android:height="30dp"
          android:width="60dp"
          android:gravity="center_horizontal">
        <rotate
            android:fromDegrees="-45"
            android:pivotX="0%"
            android:pivotY="0%"
            android:toDegrees="0" >
            <shape android:shape="rectangle" >
                <solid android:color="#6bc160" />
            </shape>
        </rotate>
    </item>

    <item   android:left="0dp"
            android:bottom="0dp"
            android:height="70dp"
            android:width="140dp"
            android:gravity="center_horizontal">
        <shape android:shape="rectangle" >
            <solid android:color="#6bc160" />
            <corners android:radius="5dp" />
        </shape>
    </item>
</layer-list>

我在layer-list drawable中显示ImageView

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="center">
    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/custom_marker"
        android:layout_centerHorizontal="true"/>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:padding="20dp">
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Some text"
        android:layout_gravity="center_horizontal"
        android:background="@android:color/transparent"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Some text (text)"
        android:layout_gravity="center_horizontal"
        android:background="@android:color/transparent"/>
    </LinearLayout>
</RelativeLayout>

在编译时,它在Android Studio中显示正确的drawable,但是当我在移动设备中运行Application时,ImageView中不会显示任何内容。有人可以帮助我为什么会这样?

0 个答案:

没有答案