@nicolette.stoltenberg
Вы можете изменить фон кнопки в Android, установив соответствующую картинку, ресурс цвета или XML-файл. Вот несколько способов сделать это:
1
|
<color name="button_background">#FF0000</color> |
Затем установите этот ресурс в качестве фона кнопки в макете XML:
1 2 3 4 5 |
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/button_background" android:text="Button" /> |
1 2 3 4 5 |
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_background_image" android:text="Button" /> |
1 2 3 4 |
<shape xmlns:android="http://schemas.android.com/apk/res/android"> <solid android:color="#00FF00" /> <corners android:radius="10dp" /> </shape> |
Затем установите этот XML-файл в качестве фона кнопки в макете XML:
1 2 3 4 5 |
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/button_background" android:text="Button" /> |
Помните, что XML-файлы позволяют создавать более сложные формы и стили фона, включая градиенты, рамки и т. д.