I am trying use relative layout for some android application.
<Button
android:layout_width="100dip"
android:background="#ff394aff"
android:text="start"
android:layout_height="wrap_content"
android:layout_marginLeft="225dp"
android:layout_marginTop="225dp"
android:id="@+id/start" android:layout_gravity="center_horizontal" android:layout_weight="0.50"/>
but the in some devices will appear in a different positons. I tried "dip" and "sp" but the problem remains. help me how to do it so that in all devices the positions be same?
I did not get when you are using marginleft then why u are using gravity to center horizontal.? try this which ever the device is , button will come at the bottom of the page with full width to screen. In this xml you can see a listview with a back button on its bottom fixed and i have tested it u can put what ever you want in the place of list and adjust button position accordingly, hope this may help you.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="1dip"
android:paddingLeft="1dip"
android:paddingRight="1dip" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="150dip"
android:layout_above="@+id/cback"
android:layout_alignParentTop="true" >
<ListView
android:id="@android:id/list"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:drawSelectorOnTop="false" />
</LinearLayout>
<Button
android:id="@+id/cback"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/btn_black"
android:text="Back"
android:textColor="#ffffff"
tools:ignore="HardcodedText" />
</RelativeLayout>