Я пытаюсь иметь 4 кнопки, и к каждой из них прикреплен нарисованный файл, который меняет их форму и цвет, но мне также нужно иметь изображение внутри каждой кнопки. Я пытался использовать метод "android: drawableStart =" @ drawable / icon_lodging_white "", но проблема в том, что изображение не остается в центре кнопки. Вот мой xml файл со всеми 4 кнопками:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
android:id="@+id/appBarMain"
layout="@layout/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize" />
<androidx.drawerlayout.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?android:attr/actionBarSize" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical">
<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:text="TextView"
android:textAlignment="textStart"
android:textAllCaps="true"
android:textColor="@color/colorPrimary"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingLeft="20dp"
android:paddingRight="20dp">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:background="@drawable/confirmed_boxes"
android:drawableStart="@drawable/icon_lodging_white" />
<Button
android:id="@+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:background="@drawable/white_confirm_boxes" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="3dp"
android:layout_weight="1"
android:background="@drawable/white_confirm_boxes"/>
<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/white_confirm_boxes" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/option_tab"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp" />
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:fitsSystemWindows="true" />
</androidx.drawerlayout.widget.DrawerLayout>
</RelativeLayout>