Set 2 buttons position in all densities
I have to buttons, one for calculate(in the LEFT) and the other(in the RIGHT) for reset EditTexts values! In fact i mak开发者_运维知识库ed this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:text="Calculer"
android:id="@+id/button"
android:layout_height="wrap_content"
android:layout_width="wrap_content">
</Button>
<Button
android:text="Reset"
android:id="@+id/button2"
android:layout_marginLeft="280px"
android:layout_height="wrap_content"
android:layout_width="wrap_content" >
</Button>
</LinearLayout>
</LinearLayout>
But the reset button doesn't change in function of the screen size if the dpi is high the reset button don't take left position(almost)! What can i solve the problem? Thakns :).
280px
Don't ever use pixels in android. Use dip(density-independent-pixels) for your views.
Also, why do you use marginLeft? Use marginRight to tell android to put your button to the right margin.
Change the android_layout_marginLeft of the Reset button to not use px. Use dp instead. See http://developer.android.com/guide/practices/screens_support.html for more examples.
精彩评论