Мне удалось стилизовать кнопки по своему вкусу с помощью чистого XML (без изображения).Вот как это выглядит:
shape_button_normal_blue.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="7dip"/>
<gradient android:startColor="@color/blue_start" android:endColor="@color/blue_end" android:angle="270" />
<stroke android:width="1dip" android:color="#80036990" />
<padding android:left="5dip" android:right="5dip" android:top="7dip" android:bottom="7dip"/>
</shape>
Подобно тому, как я описывал другие формы для нажатия / отключения / etc
Вот мой selector_button_blue:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
android:drawable="@drawable/shape_button_normal_blue" />
<item android:state_window_focused="false" android:state_enabled="false"
android:drawable="@drawable/shape_button_disabled" />
<item android:state_pressed="true"
android:drawable="@drawable/shape_button_selected" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/shape_button_focused_blue" />
<item android:state_enabled="true"
android:drawable="@drawable/shape_button_normal_blue" />
<item android:state_focused="true"
android:drawable="@drawable/shape_button_normal_blue" />
<item android:drawable="@drawable/shape_button_disabled" />
</selector>
И, наконец, мой стиль:
<style name="MyBlueButton" parent="@android:style/Widget.Button">
<item name="android:background">@drawable/selector_button_blue</item>
<item name="android:layout_marginLeft">1dp</item>
<item name="android:layout_marginRight">1dp</item>
<item name="android:layout_marginTop">5dp</item>
<item name="android:layout_marginBottom">5dp</item>
<item name="android:textColor">@color/white</item>
<item name="android:textSize">18dp</item>
<item name="android:textStyle">bold</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
</style>
Я использую эти кнопки очень хорошо с текстом.Счастлив и горд:)
Теперь мне нужно поставить на них значок.Я вижу, что есть рисунок Top / Bottom / Left / Right, но он не делает то, что мне нужно.Что мне здесь не хватает?Как мне сделать это красиво и по центру?
<Button style="@style/MyBlueButton" android:layout_marginTop="0dp" android:text="" android:layout_width="0dp" android:layout_weight="0.15"
android:drawableTop="@drawable/ic_accept"/>
![enter image description here](https://i.stack.imgur.com/dt0mf.png)