Mammadali Alizadeh
Mammadali Alizadeh

Reputation: 325

How to set foreground Image to ImageButton?

I am new in Android App development. I want to set Foreground image to Image button in API level 19. How to do this?

enter image description here

Upvotes: 0

Views: 1753

Answers (1)

Tam Huynh
Tam Huynh

Reputation: 2487

For the sample code, use this for a layout of 1 answer:

<FrameLayout
    android:id="@+id/answer_section"
    android:layout_width="100dp"
    android:layout_height="100dp">

    <ImageView
        android:id="@+id/answer_background"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/house_img"/>

    <ImageView
        android:id="@+id/answer_check"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/check_img"/>
</FrameLayout>

You use 2 different ImageView for 2 images so they can work separately, like doing animation, show/hide with conditions...

Upvotes: 1

Related Questions