0

How to display 3 buttons (text + icons centered) equidistant on screen horizontally ?

Here is my code. This method works but the icon is not centered

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:weightSum="3"
    android:layout_below="@id/message">
<Button android:id="@+id/action_like"
    android:text="Like"
    android:layout_width="0dp"
    android:gravity="center"
    android:layout_weight="1"
    android:layout_height="wrap_content"
    android:textColor="#104e75"
    android:textSize="10sp"
    android:background="#FFFFFF"
    android:drawableLeft="@drawable/ic_action_like" />
<Button
    android:id="@+id/action_comment"
    android:text="Comment"
    android:layout_width="0dp"
    android:layout_weight="1"
    android:gravity="center"
    android:layout_height="wrap_content"
    android:textColor="#104e75"
    android:textSize="10sp"
    android:background="#FFFFFF"
    android:drawableLeft="@drawable/ic_action_comment" />
<Button 3 ....>

Valy Dvweb
  • 35
  • 8
  • possible duplicate of [Aligning drawableLeft with text of button](http://stackoverflow.com/questions/14668219/aligning-drawableleft-with-text-of-button) – corsair992 Jan 17 '15 at 22:23
  • yes....i know that post, but I'm looking for a different method of setting the paddingLeft when the width is not fixed (it's variable) – Valy Dvweb Jan 18 '15 at 18:11
  • There are two solutions mentioned in the accepted answer in that post, although it seems that the author forgot to specify central gravity. – corsair992 Jan 18 '15 at 18:18

0 Answers0