I am trying to achieve the result as shown in Pic1. Tried setting gravity, paddingleft etc but the drawable image comes in the right end and not next to Text(SHown in Pic 2
). Can anyone suggest how to align the image next to TextView? Also how to set the size of drawable?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="@drawable/separator"
android:padding="10dp">
<TextView
android:id="@+id/sms"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_weight="1"
android:drawableEnd="@drawable/message"
android:drawableRight="@drawable/message"
android:gravity="center"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:text="SMS" />
<TextView
android:id="@+id/call"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:drawableEnd="@drawable/call"
android:drawableRight="@drawable/call"
android:gravity="center"
android:text="CALL" />
<TextView
android:id="@+id/email"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:drawableEnd="@drawable/mail"
android:drawablePadding="3dp"
android:drawableRight="@drawable/mail"
android:text="MAIL" />
Try to build around this.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:orientation="horizontal"
android:padding="10dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1">
<TextView
android:id="@+id/sms"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:gravity="center"
android:drawableRight="@drawable/message"
android:text="SMS" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1">
<TextView
android:id="@+id/call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/call"
android:gravity="center"
android:text="CALL" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1">
<TextView
android:id="@+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableRight="@drawable/mail"
android:gravity="center"
android:text="MAIL" />
</LinearLayout>
</LinearLayout>

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With