Use Linearayout, not RelativeLayout.LinearLayout allows you to split your screen in two vertically or horizontally, as you want, using the layout_weight property of LinearLayout.
With layout_weight you can specify the aspect ratio between several views. For instance. you have a MapView and a table that should display some additional information on the map. The map should use 3/4 of the screen, and the table should use 1/4 of the screen. Then you set the layout_weight of the map to 3 and the layout_weight of the table to 1.
Write your code as shown below, which divides the screen into two parts.
<LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:weightSum="2" android:orientation="vertical"> <LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:layout_weight="1"> </LinearLayout> <LinearLayout android:layout_height="match_parent" android:layout_width="match_parent" android:layout_weight="1"> <LinearLayout>
In the android code : orientation, the orientation is indicated, if you use vertical, then it will massage its child vertically, and if you specify horizontal, it will arrange it horizontally.
source share