How to create layout with android's different display size
My problem born when i create layout in xml file from graphics tool. RelativeLayout is awful! i don't know which layout to use.. When i put an imageview and a imagebutton, in emulator will displayed in a bad way, one apon the other. what can i do? is there a good tutoria开发者_运维技巧l on which i can learn how to resize image and layout in percent of different displays size? i Try this :
<RelativeLayout android:layout_width="match_parent" android:id="@+id/relativeLayout1" android:layout_height="match_parent">
<LinearLayout android:layout_width="wrap_content" android:id="@+id/linearLayout1" android:orientation="vertical" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentLeft="true">
<ImageView android:id="@+id/imageView1" android:src="@drawable/testotrova" android:layout_width="243dp" android:layout_height="48dp"></ImageView>
</LinearLayout>
<ImageButton android:layout_width="wrap_content" android:src="@drawable/info" android:layout_height="wrap_content" android:id="@+id/imageButton1" android:layout_alignParentTop="true" android:layout_alignParentRight="true"></ImageButton>
</RelativeLayout>
but when i display it isn't good
Regarding support for multiple screens, have a look here.
You will need to add different layouts for screen size small, normal and large.
They are displayed one upon the other because you are using RelativeLayour and they are both (Image and text) anchored to the upper left:
android:layout_alignParentTop="true" android:layout_alignParentLeft="true"
I strongly suggest you to use LinearLayout if you have only a few items. (http://www.learn-android.com/2010/01/05/android-layout-tutorial/4/)
For your image size, if you want a percent, please use:
android:layout_height="0dip"
android:layout_weight="1"
http://developer.android.com/resources/articles/layout-tricks-efficiency.html
精彩评论