Register Login

Split Screen using Multiple Layout

Updated May 17, 2019

How to Split Screen Layout in Android

Please follow the steps below in order to use split screen layout in Android App:

1.Splitting the screen using multiple layouts in a single activity

2.Start a new project

3.Remove the 'Hello world' text.

4.Click on the text tab.

5.Change Relative layout to Linear layout.

6.Add android: orientation = 'vertical'

7.Go to the Design tab.

8.Go to Layout > relative layout. Drag relative layout under the component tree. Add another relative layout under the component tree.

9.Go to the Text tab. Add a line android:layout_weight='.5'. You can notice the size on the adjoining screen.

To Remove the Action Bar

10.Go to res > values > styles.xml

11.Replace Light.DarkActionBar with NoActionBar.

12.Go to activity.xml, then the Design tab. You will notice that the action bar has disappeared from the screen.

13.Go to Widgets > Button. Drag the button to the center of the screen.

14.Click on the WebView and drag it on the bottom portion of the window.

15.Go the Text tab. Remove the unwanted code highlighted in blue.

16.Replace wrap content with match parent.

Complete Code

res >> layout >> activity_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools" 
	android:id="@+id/activity_main"
	android:layout_width="match_parent"
	android:layout_height="match_parent" 
	android:paddingLeft="16dp"
	android:paddingRight="16dp"
	android:paddingTop="16dp"
	android:paddingBottom="16dp"
	android:orientation="vertical"
	tools:context="com.sabithpkcmnr.multiplewindow.MainActivity">
	<RelativeLayout
		android:layout_width=".5"
		android:layout_width="match_parent"
		android:layout_height="match_parent">
		<Button
			android:text="Button"
			android:layout_width="match_parent"
			android:layout_height="match_parent"
			android:layout_centerVertical="true"
			android:layout_centerHorizontal="true"	
			android:id="@+id/button" />
	</RelativeLayout>
	<RelativeLayout
		android:layout_width=".5"
		android:layout_width="match_parent"
		android:layout_height="match_parent">
		<WebView
			android:layout_width="match_parent"
			android:layout_height="match_parent" />
		</WebView>	
	</RelativeLayout>
</LinearLayout>

 


×