Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine multiple backgrounds on android XML?

Can I combine my own android drawable and ?android:selectableItemBackground...? I searched a lot but I can't find the right answer... For example lets say I have a simple button and I want this:

<Button
    android:id="@+id/bTest"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="?android:selectableItemBackground" | @drawable/myDrawable/>

Any ideas?

like image 849
Unixyz Avatar asked Jul 28 '16 11:07

Unixyz


1 Answers

How about using FrameLayout

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@drawable/myDrawable">
    <Button
        android:id="@+id/bTest"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="?android:selectableItemBackground"/>
</FrameLayout>

or using ImageButton

<ImageButton
    android:id="@+id/bTest"
    android:src="@drawable/myDrawable"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="?android:selectableItemBackground"/>
like image 160
Taichiro Suzuki Avatar answered Nov 04 '22 18:11

Taichiro Suzuki