Search code examples
androidnavigation-drawerandroid-scrollview

Android Scrollview doesn't work behind navigation drawer


I have an Activity which have navigation drawer that works perfectly but behind the drawer ScrollView doesn't work.

Here is my xml code,

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="4dp"
    tools:context="com.bala.beautytipstamil.Content">

    <WebView
        android:id="@+id/txtTitle"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:textSize="15sp" />

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/include"
        android:layout_below="@+id/txtTitle">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/imgContent"
                android:layout_width="match_parent"
                android:layout_height="150dp" />

            <WebView
                android:id="@+id/txtContent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </LinearLayout>
    </ScrollView>

    <include
        android:id="@+id/include"
        layout="@layout/buttons"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <ListView
            android:id="@+id/navList"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:layout_gravity="left|start"
            android:background="#ffeeeeee" />
    </android.support.v4.widget.DrawerLayout>

</RelativeLayout>

Please help!


Solution

  • Put your ScrollView inside DrawerLayout like below code. just copy and paste it.

    <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/drawer_layout"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
        <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingTop="4dp"
            tools:context="com.bala.beautytipstamil.Content">
    
            <WebView
                android:id="@+id/txtTitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:textSize="15sp" />
    
            <ScrollView
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_above="@+id/include"
                android:layout_below="@+id/txtTitle">
    
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
    
                    <ImageView
                        android:id="@+id/imgContent"
                        android:layout_width="match_parent"
                        android:layout_height="150dp" />
    
                    <WebView
                        android:id="@+id/txtContent"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent" />
                </LinearLayout>
            </ScrollView>
    
            <include
                android:id="@+id/include"
                layout="@layout/buttons"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_alignParentBottom="true"
                android:layout_alignParentLeft="true"
                android:layout_alignParentStart="true" />
    
    
        </RelativeLayout>
    
        <ListView
            android:id="@+id/navList"
            android:layout_width="200dp"
            android:layout_height="match_parent"
            android:layout_gravity="left|start"
            android:background="#ffeeeeee" />
    
    
    </android.support.v4.widget.DrawerLayout>