What is imageview

Android imageview is used to display the image in android.

In my program you look the imageview display the image and textview display the text imageview demo.


ImageView:.

In this section i am going to show the imageview with practical example.

First open the android studio and create a project and give the name of your project like ImageViewDemo.

The screenshots of the program is as follows:

Smiley face Smiley face

Drag and drop the one ImageView and one TextView from pallet . Open the activity_main.xml file and code look like this


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    tools:context=".MainActivity">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/screen"
        android:layout_centerHorizontal="true"
        />

    <TextView
        android:id="@+id/textView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginTop="300dp"
        android:layout_marginLeft="120dp"
        android:text="ImageView demo"
        android:textSize="20sp"
        />


</RelativeLayout>
       

In above code you need to do the things first to open google and download the image and copy and paste into drawable folder.Write the name of image as screen in my case you can write any name.


Open the MainActivity.java file and code look like this.you do not have need to write any code in MainActivity.java file.


package com.example.niitpc.myapplication;

import android.app.DatePickerDialog;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;

import java.sql.Time;
import java.util.Calendar;

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);



    }
}

    

ImageView

What is imageview for video Click here

Smiley face                     Smiley face