Android : Auto resize an imageView

on Sunday, August 17, 2014


I have a Brick image and i am trying to create a 6x6 table of the imageView. i tried many ways to set the imageview to auto resize by the screen size but i didn't success. that is a part of my XML's code:



<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_below="@+id/relativeLayout"
android:paddingTop="10dp"
android:paddingRight="10dp"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:gravity="center_vertical|center_horizontal">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:weightSum="1">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/s_1"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@drawable/brick_clean" />


<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/s_2"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@drawable/brick_clean" />

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/s_3"
android:layout_marginRight="5dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:scaleType="fitXY"
android:adjustViewBounds="true"
android:src="@drawable/brick_clean" />



</LinearLayout>


</RelativeLayout>


and that is my result: enter image description here


what i want is all the imageViews will automatic resize to the same width and height and fill all the linearLayout. how will i do it?


0 comments:

Post a Comment