How to use Images as buttons in android? -


this question has answer here:

i developing recipe application,it salad recipe application, want add each salad items images 1 one in scroll view,when user clicks image of salad item want display recipe details.how can implement on application, can use pictures buttons?? can help??

i tried setting images buttons.is right way??

i created xml file called images_button in drawable folder

<?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_focused="true" android:state_pressed="false" android:drawable="@drawable/first" /> <item android:state_focused="true" android:state_pressed="true" android:drawable="@drawable/first_pressed" /> <item android:state_focused="false" android:state_pressed="true" android:drawable="@drawable/first_pressed" /> <item android:drawable="@drawable/first" /> </selector> 

and main xml file is

<button     android:id="@+id/button1"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@drawable/button_image"     /> 

directly use imagebutton inside layout xml file.

<imagebutton         android:id="@+id/imagebutton1"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:src="@drawable/button_image" /> 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -