Ok, i have two buttons in linear layout:
Display display=getWindowManager().getDefaultDisplay();
int width=display.getWidth();
btn1.setWidth(width/2);
btn2.seTwidth(width/2);
Set anything in xml file then first find width of device then set width half to both button Now On every device they will look exactly same
Set android:layout_weight="1" in the containing layout The linear layout should have android:orientation set as horizontal. And then the inside buttons should have the following:
android:layout_width="0dp"
android:layout_weight="0.5"
You can set them in linear layout nested in relative layout like this
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="@+id/bestBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:layout_marginBottom="5dp"
android:textAllCaps="false"
android:textSize="16sp"
android:textColor="@color/grey_light2"
android:background="@drawable/sharefb_btn"
android:text="@string/sharefb" />
<Button
android:id="@+id/playBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/grey_light2"
android:textAllCaps="false"
android:textSize="16sp"
android:layout_marginBottom="50dp"
android:textStyle="bold"
android:background="@drawable/puzzle_opening_btn_ncvtelen_3"
android:text="@string/playagain" />
</LinearLayout>
and you will get somethiing like that