开发者

Layout or image fixing vertically & horizontally

开发者 https://www.devze.com 2023-04-13 04:13 出处:网络
Hi Guys I m new to android, so please help me with some info about,how can i fix the layout for different versions of android sdk\'s.

Hi Guys I m new to android, so please help me with some info about,how can i fix the layout for different versions of android sdk's. For example: I m having a series of images in my app. & ev开发者_开发知识库ery image is having the same size but if i have fixed these size of images for android sdk 2.2 then when i run this app. in android sdk 3.0 emulator then the image becomes small for it,what i want is to that i want the images to be automatically resized according to the sdk versions whether its hold vertically or horizontally, so that my app. can me installed on any cell phone & i don't have to stretch the images according to various sdk's. I hope there might be some solution for this.... please help me with a sample code if anyone knows about it. Thanks in advance guys!!


while surfing web i found a piece of code relating your problem ... use it if you found it worthy

to auto adjustment of image add the following property to your image view as written below

for xml

android:scaleType="fitXY"

for java

myImageView.setScaleType(ScaleType.FIT_XY);


refer,

http://developer.android.com/guide/practices/screens_support.html

and

http://developer.android.com/guide/practices/ui_guidelines/index.html


you should set the image's height and width wrap_content and the layout wrapping this image with fill_parent it will solve the problem and re size the image automatically as below is example for better understanding of what i am saying

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"


>

<ImageView
 android:layout_width="wrap_content" 
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/myImage"
 />
 </LinearLayout>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号