Saturday, 31 January 2015



On my XML File, I get this notification:



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


My xml code is like this:



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


And i have a round xml:



<shape xmlns:android="http://ift.tt/nIICcg" 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>


Now my graphical layout look like this: enter image description here


I read some suggestions about how to join ImageView and TextView, android:drawableTop="@drawable/medical14", but when i join them in TextView, the graphical layout not seems like i want.


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


My new graphical layout:


enter image description here


No comments:

Post a Comment