2013-07-23 10 views
6

Okey chłopaki, mam przycisk podobny do przedstawionego poniżej enter image description hereJak ustawić odległość między widokiem tekstowym a rysowaniem w przycisku?

Chcę zmienić odległość między tekstem a rysunkiem. jak oszukać tego?

to jest mój kod XML za pomocą przycisku

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

i to jest CAGButton w 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, dzięki w Adv. :)

+0

Czy masz rozwiązanie tego problemu? – gZerone

+0

hi @gZerone wysłałem moją odpowiedź. możesz to sprawdzić. –

+0

dziękuję RR12. Mam twoje rozwiązanie :) – gZerone

Odpowiedz

1

Przy okazji rozwiązałem mój problem, wprowadzając pewne zmiany w moim stylu przycisku. tak stać tak:

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

myślę, że wystarczy ustawić wyściółka lewo &/prawo do najlepszego punktu, który pasuje do naszego stylu.

1

Oto rozwiązanie.

    <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" /> 
Powiązane problemy