Hi am confused with image button options in android. I have created three image buttons with the following xml
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:src="@drawable/folder_add" />
<ImageButton
android:id="@+id/imageButton4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageButton1"
android:layout_toLeftOf="@+id/imageButton1"
android:src="@drawable/search" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageButton4"
android:layout_toLeftOf="@+id/imageButton4"
android:src="@drawable/advancedsettings"
style="?android:attr/borderlessButtonStyle" />
But the out is like button with image on its .. Please help me to show the image only as button..Thnx in advance!
Displays a button with an image (instead of text) that can be pressed or clicked by the user. By default, an ImageButton looks like a regular Button , with the standard button background that changes color during different button states.
To avoid confusion rename your button android:onClick="onClick" , like android:onClick="imageButtonOnClick" . Thank you!
You cannot set text to ImageButton because it has no method as setText() or android:text property. ImageButtons can't have text (or, at least, android:text isn't listed in its attributes). It looks like you need to use Button (and look at drawableTop or setCompoundDrawablesWithIntrinsicBounds(int,int,int,int)) .
Put this tag in your ImageButton
android:background="@null"
This will do it.
You can also use a transparent color: This will solve your problem.
android:background="@android:color/transparent"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With