I have a listview in android and i have a imageview in it
I am populating images into the list view i have a output like below::
listview_item.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:descendantFocusability="blocksDescendants" >
<ImageView
android:id="@+id/flag"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
How can i make something like this below
Any ideas ! ... i am trying to achieve this in list view
add scaleType
to ImageView
<ImageView
android:id="@+id/flag"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:src="@drawable/ic_launcher"
android:scaleType="fitXY"/>
SET android:adjustViewBounds="true"
attribute in xml or imageView.setAdjustViewBounds(true)
in Java.
ALSO
You can use android:scaleType="fitXY"
in XML:
<ImageView
android:id="@+id/flag"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:src="@drawable/ic_launcher" />
There are Many option for android:scaleType
Android have provided us many attributes to work with ImageView.
You can use adjustViewBounds and scaleType property in your case. Check example below:
<ImageView
android:id="@+id/flag"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@drawable/ic_launcher" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.