Little confused with the design in android..suppose i need to position two blocks
as in the figure..what s开发者_开发问答hall i do?..if we use pixels the design looks different in different phones.
Design should be fixed in all phones..but how without using px we can design as above
Use two LinearLayout in your layout xml and set layout_marginLeft,layout_marginTop,layout_marginRight in dip according to the need.
See the following layout, its very similar to the one you want:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:text="Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="50dip"
android:layout_marginLeft="30dip"
></Button>
<Button
android:text="Button02"
android:id="@+id/Button02"
android:layout_below="@id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginTop="140dip"
android:layout_marginRight="30dip"
></Button>
</RelativeLayout>
Hope this will solve your issue.
You could generate the layout in Java by getting the screen size and placing two objects (defined in xml or java) into the parent layout, taking into account the ratios.
If dip is unable 2 solve ur problm , surely any of these approaches will work :
1) take a 9patch backgroud with proportionate padding . now put first textview with gravity left|top and second with grvity right|bottom . done
or
2)Take two child of a vertical linearlayot with layout_weight=1 , so will each will take 50% height now to put put textview center vertical . now lets try fix it horizontally.4 each text take two child textview with layout_weight=1 ,put text center_horizontal .for upper text male second invisible n for lower make first one invisible ......
精彩评论