Android布局警告:此标记及其子标记可以替换为一个<textview>和一个复合drawable </textview>

时间:2015-01-31 17:38:03

标签: android xml android-layout

在我的XML文件中,我收到此通知:

This tag and its children can be replaced by one <TextView/> and a compound drawable

我的xml代码是这样的:

<LinearLayout
    android:id="@+id/pharmacyBtn"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:gravity="center">

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/round"
        android:contentDescription="@null"
        android:gravity="center_vertical|center_horizontal"
        android:padding="14sp"
        android:src="@drawable/medical14" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#054126"
        android:textStyle="bold"
        android:text="@string/pharmacyBtn" />
</LinearLayout>

我有一个圆形的xml:

<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
    <solid android:color="#00FFFFFF"/>
    <stroke android:width="2dp" android:color="#c7d23e" />

    <corners android:bottomRightRadius="24dip"
        android:bottomLeftRadius="24dip"  
        android:topRightRadius="24dip"
        android:topLeftRadius="24dip"/>

</shape>

现在我的图形布局如下所示: enter image description here

我读了一些关于如何加入ImageView和TextView的建议,android:drawableTop =&#34; @ drawable / medical14&#34;,但是当我在TextView中加入它们时,图形布局似乎不是我想要的。

我的新xml:

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#054126"
        android:textStyle="bold"
        android:background="@drawable/round"
        android:drawableTop="@drawable/medical14"
        android:text="@string/pharmacyBtn" />

我的新图形布局:

enter image description here

0 个答案:

没有答案