android make image buttons take on the same background selector/drawable as text buttons

16 Views Asked by At

The text button will take on a background based on the app's primary colour, but the ImageButton has a grey background.

From various web and AI searches, I have tried the following, but they either do nothing, cause the button to disappear, or the layout inflation fails:

    android:background="?android:attr/selectableItemBackground"

and

    style="?android:attr/buttonStyle"

and

       android:background="?android:attr/buttonStyle"
 <ImageButton
        android:id="@+id/btn_take_picture"
        android:background="?android:attr/selectableItemBackground"
        android:layout_width="110dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="50dp"
        android:layout_marginEnd="50dp"
        android:elevation="2dp"
        android:text="Photo"
        android:src="@drawable/ic_menu_camera"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintEnd_toStartOf="@id/vertical_centerline" />

    <Button
        android:id="@+id/btn_record_video"
        android:layout_width="110dp"
        android:layout_height="wrap_content"
        android:layout_marginBottom="50dp"
        android:layout_marginStart="50dp"
        android:elevation="2dp"
        android:text="Record"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toEndOf="@id/vertical_centerline" />

Quite why this isn't done as standard, I don't know.

0

There are 0 best solutions below