Reputation: 427
I am new in Android development.I created a simple project with a simple button.I'd like to set image as background (see image). I've used android:src="@drawable/id_image" and android:background="@drawable/id_image2" but the image does not appear on the entire surface of button.Any help would be appreciated
Upvotes: 0
Views: 140
Reputation: 2954
You can try something like this
<RelativeLayout
android:layout_width="250dp"
android:layout_height="400dp"
android:background="your_background_goes_here"
android:foreground="?android:attr/selectableItemBackground"
android:clickable="true"
android:centerInParent="true">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="your_icon_above_background"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text_for_your_image"/>
</RelativeLayout>
Upvotes: 0
Reputation: 179
Android, you can use android.widget.ImageButton to display a normal “Button“, with a customized background image.
<ImageButton
android:id="@+id/top_bar_btn_right_img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:src="@drawable/ic_filter" />
Upvotes: 1
Reputation: 89
when you add your button , you just go to the menu of properties and choose background / drawable and choose your image
Upvotes: 0
Reputation: 20258
You might use android:src
and android:background
for adding two images.
Upvotes: 0