1

how can i create a responsive Layout for android where i have a Navigation Drawer in portrait mode and 2 columns in landscape mode?

I don't want to use libraries, just basic Android Stuff...

[Here is a picture... i'm not allowed to post them direct]1

I tried it with Fragments for Navigation and 2 different layouts in 'layout' and 'layout-land'.

Landscape:

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.fun.store.test.ActivityMain">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:weightSum="3">
    <fragment android:id="@+id/navigation_drawer"
        android:layout_weight="2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="start" />
    <FrameLayout
        android:id="@+id/container"
        android:layout_weight="1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:name="com.fun.store.test.NavigationDrawerFragment"/>
</LinearLayout>

and Portrait:

<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.fun.store.test.ActivityMain">
<FrameLayout
    android:id="@+id/container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
<fragment android:id="@+id/navigation_drawer"
    android:layout_width="@dimen/navigation_drawer_width"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:name="com.fun.store.test.NavigationDrawerFragment" />
</android.support.v4.widget.DrawerLayout>

But it doesn't work because of the Drawer...

Is there any example how to do this?

Pranav Singh
  • 17,079
  • 30
  • 77
  • 104
littelteddy
  • 29
  • 1
  • 4

0 Answers0