image - how to keep aspect ratio with different android devices -
so i'm trying set image within scrollview , have image stretch fit different sized screens, it'll stretch horizontally, vertically comes out messed up. i've read many pages of people similar problems, solutions never work me. i've tried every different combination possible using different "scaletype","layout_width" , "layout_height", along trying changing other things around. closest i've gotten getting work shown in code below, using scaletype="centercrop", 1 stretches image vertically in ratio, cuts off big chunk of image top , bottom, it'll scroll , downwards image, middle part shows. image 480x5500 jpeg, if matters. before started messing that, app worked fine on phone, later realized image crunched when tried on tablet. there's gotta way in xml right? don't want have things image in java code part. hoping able using 1 image, don't want have utilize different image different screen sizes. please help, thanks.
<?xml version="1.0" encoding="utf-8"?> <scrollview xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollview1" android:layout_width="match_parent" android:layout_height="match_parent" > <imageview android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustviewbounds="true" android:scaletype="centercrop" android:src="@drawable/paper" /> </scrollview>
may help you, create both height , width wrap_content
of imageview
android:layout_width="wrap_content" android:layout_height="wrap_content"
and no need scrollview
here.
android image ratio aspect
No comments:
Post a Comment