The introduction of Android User Interface (UI) ImageView

Android ImageView (Source Google Images)

ImageView is a class used to display the image file in the app. ImageView comes with a choice of different configurations to support different types of scale.

Some of them are scaleTypes configuration properties, center, center_crop, fit_xy, fitStart etc.

We can also set the image source at run time programming in java class. For that we use setImageResource () method as shown in the example code below:

ImageView image=(ImageView) findViewById(R.id.imageView1);
 
image.setImageResource(R.drawable.fox);
 
//note: "fox.png" is pic name. and this name in the drawable folder

Android ImageView used to display the image file. It is defined in the XML layout in the following way.

<ImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="5dp"
            android:src="@drawable/ic_launcher" />

Android ImageView ScaleType

CENTER: Showing centered on the display without scaling.

CENTER_CROP: Center the image on the display .

FIT_CENTER:  Improve the image to fit the display.

CENTER_INSIDE : Improve the image to fit the display.

Source: Master Android (App)

Post Author: Study