Search code examples
androidandroid-layoutandroid-activityandroid-imageviewandroid-image

I want to enter images in my android activity. Where should I put the images?


I'm using Android Studio 1.2.2 I made a form activity and I want to insert an image. Where should I put the image? What changes I have to do in my mainactivity.java file?


Solution

  • You can use Android's ImageView tag. You need to write it inside .xml file of your activity. You can take reference of it from android's devloper's website.

    In Andorid studio you can not directly drag & drop images.

    It will be good for you to take reference of any example.Here is the ImageView xml code.

     <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/android" />
    

    You can now make this ImageView reference in your MainActivity (Java) like below:

    ImageView imageView; imageView = (ImageView) findViewById(R.id.imageView1);