0

how to create a xml layout for activity in center with borders surrounded in tablet view like picture linked here: (specified in red)

xml layout

I want to place my activity in center and two columns in sides is there a standard way to create this layout?

h.kelidari
  • 800
  • 1
  • 11
  • 20

1 Answers1

0

Create your layout like this

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#f5f5f5" >
    </LinearLayout>

    <View
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:background="#000000" />
    <!-- Activity layout -->

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="2" >
    </LinearLayout>

    <View
        android:layout_width="2dp"
        android:layout_height="match_parent"
        android:background="#000000" />

    <LinearLayout
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:background="#f5f5f5" >
    </LinearLayout>

</LinearLayout>

Just replace color code in background to get your desired display.enter image description here

Jitender Dev
  • 6,907
  • 2
  • 24
  • 35