Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Image on Image button not displayed

I facing the problem that, I cant add new image button to my XML file.I added my icons to Drawable, but It cannot show in image button. XML shows an error ImageButton class not found. How can I solve this ?

I got the following error in xml

The following classes could not be found: - ImageButton (Change to android.widget.ImageButton, Fix Build Path, Edit XML)

Here is my xml

   <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:orientation="vertical" >

       <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="109dp"
        android:src="@drawable/facebook" />

     </RelativeLayout>
like image 475
doubter Avatar asked Jan 22 '14 05:01

doubter


1 Answers

Why dont you try a simple button instead of image button. Here is a code i have on some of my buttons with image. android:drawableTop="@drawable/three" : this is basically the image android:background="@drawable/buttonstyles" : this is a style for the button. No need to use it. Or the other layout features i have.

 <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBottom="@+id/button2"
        android:layout_alignParentRight="true"
        android:layout_marginRight="20dp"
        android:background="@drawable/buttonstyles"
        android:drawableTop="@drawable/three"
        android:onClick="goToSettings"
        android:text="Settings" />
like image 81
lantonis Avatar answered Oct 01 '22 12:10

lantonis