android - How to center the text inside a Button regardless of drawableLeft? -


i want text centered in button. whenever add android:drawableleft xml attribute button, offsets text. how can fix that?

share button

the way managed fix setting negative number in android:drawablepadding:

enter image description here

but i'm looking cleaner solution achieve it.

so ended going lesser of evils, , that's placing drawable , text inside relativelayout:

<relativelayout     android:layout_width="match_parent"     android:layout_height="wrap_content"     style="@style/button.buttongray"     android:id="@+id/share_button">      <imageview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/btn_share"/>      <textview         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:textcolor="@android:color/black"         android:textstyle="bold"         android:layout_centerinparent="true"         style="@style/textnormalweight"         android:text="@string/post_share"/>  </relativelayout> 

the relativelayout receives click events , acts , looks button.


Popular posts from this blog