Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android : make imageview full screen size

Tags:

android

I know this has been asked in stackoverflow few times ; I tried all the answers in vain. I have a custom imageview (for scroll/zoom) in my android app. I programmatically set the image to be displayed in the imageview (so, the imageview is empty in the IDE). However I try, there seems to be some padding to the left & top of the imageview which am unable to remove. Please help. This is the code (the following is one of the possible options I tried from stackoverflow) It's not possible to change the scaletype from matrix as my code for touch/zoom depends on the matrix scale type.

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".ActivityHome" >

<myTouchImageView
android:id="@+id/imgView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="0dp"
android:layout_marginTop="0dp"
android:scaleType="matrix" />

</RelativeLayout>

However, this is what I get :

enter image description here

like image 610
Jean Avatar asked Jul 06 '26 11:07

Jean


1 Answers

1- Change android:scaleType="matrix" to android:scaleType="fitXY" which means that the image will be stretched to fit all the sides of the parent ( ImageView ) , but this will change its resolution, if you want to keep the resolution use android:scaleType="centerInside".

like image 153
Omar HossamEldin Avatar answered Jul 19 '26 20:07

Omar HossamEldin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!