How to set the distance between text view and button click?

Guys, I have a button, as in the picture below enter image description here

I want to change the distance between text using drawable. how to fool it?

this is my xml for the button

<Button android:id="@+id/ButtonCancel" style="@style/CAGButton" android:drawableLeft="@drawable/selector_ic_cancel" android:text="@string/layer_button_cancel" /> 

and this is CAGButton in style.xml

 <style name="CAGButton" parent="@android:style/Widget.Button"> <item name="android:drawablePadding">3dip</item> <item name="android:textColor">@color/cag_brown</item> <item name="android:layout_width">0dp</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_weight">1</item> <item name="android:background">@drawable/selector_button"</item> </style> 

okey, thanks in adv. :)

+6
source share
2 answers

Btw I solved the problem with the changes made to my button style. therefore it becomes like this:

  <style name="CAGButton" parent="@android:style/Widget.Button"> <item name="android:gravity">center</item> <item name="android:paddingLeft">20dp</item> <item name="android:paddingRight">20dp</item> <item name="android:textColor">@color/cag_brown</item> <item name="android:layout_width">0dp</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_weight">1</item> <item name="android:background">@drawable/selector_button</item> </style> 

I think we just need to set padding left & / right to the best point that matches our design.

+1
source

Here is the solution.

  <Button android:id="@+id/xyz" android:layout_width="wrap_content" android:layout_height="30dp" android:layout_weight="1" android:background="@drawable/button_shape" android:drawableLeft="@drawable/location" android:drawablePadding="2dip" android:gravity="center" android:paddingLeft="20dip" android:paddingRight="16dip" android:singleLine="true" android:text="XYZ" android:textColor="#FFF" /> 
+1
source

Source: https://habr.com/ru/post/950048/


All Articles