put linearlayout under sliding drawer

383 views Asked by At

i have a linear layout and now i want to put all my content under sliding drawer (right to left sliding drawer). my linear layout is:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

        android:id="@+id/mainpage"
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:pj="http://schemas.android.com/apk/res/com.sha_ver1"

        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/safhe_asli"
        >

    <RelativeLayout
            android:layout_weight="0.5"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">
        <ImageView
                android:src="@drawable/logo"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/imageView"
                android:layout_gravity="left|top"
                />
        <TextView
                style="@style/content"
                android:id="@+id/selected_item"

                />

        <Button
                android:id="@+id/btn"
                android:background="@drawable/rounded_edges"
                android:textColor="@android:color/white"
                android:textSize="20sp"
                android:gravity="center"
                android:layout_gravity="center"
                android:text="@string/readmore"
                android:padding="5dp"
                android:layout_alignLeft="@+id/selected_item"
                android:layout_alignRight="@+id/selected_item"
                android:layout_alignBottom="@+id/selected_item"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginBottom="-40dp"


                ></Button>



    </RelativeLayout>
    <LinearLayout


            android:layout_weight="0.5"
            android:layout_height="fill_parent"
            android:padding="5dip"
            android:gravity="top"
            android:layout_width="fill_parent"

            >
        <com.sha_ver1.controls.Carousel

                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:id="@+id/carousel"
                pj:UseReflection="false"
                pj:Items="@array/entries"
                pj:Names="@array/names"
                pj:SelectedItem="0"
                android:animationDuration="400"
                />
    </LinearLayout>
</LinearLayout>

and my sliding drawer code is :

 <SlidingDrawer
            android:id="@+id/drawer"
            android:layout_alignParentRight="true"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="horizontal"
            android:handle="@+id/handle"
            android:content="@+id/content">


        <ImageView
                android:id="@id/handle"
                android:layout_width="100dp"
                android:layout_height="500dp"
                android:src="@android:color/white"
                />

        <LinearLayout
                android:id="@id/content"

                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:orientation="vertical">
            <Button
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:text="Big Big Button"/>

        </LinearLayout>

    </SlidingDrawer>

I'm new in android and I'm so tired of trying. i will be appreciate of anyone who can help me .

1

There are 1 answers

1
Edward van Raak On BEST ANSWER

This is an example where the drawer takes up 50% of the screen and the content the other 50%. I'm not sure if this is what you wanted but I hope it helps you somehow.

Edit: Something like this?

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/mainpage"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">
        <RelativeLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            >

            <ImageView
                android:id="@+id/imageView"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="left|top" />

            <Button
                android:id="@+id/btn"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginBottom="-40dp"
                android:gravity="center"
                android:padding="5dp"
                android:textColor="@android:color/white"
                android:textSize="20sp"


                ></Button>


        </RelativeLayout>

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="0.5"
            android:gravity="top"

            android:padding="5dip">

        </LinearLayout>
    </LinearLayout>

    <SlidingDrawer
        android:id="@+id/drawer"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentRight="true"
        android:content="@+id/content"
        android:handle="@+id/handle"
        android:orientation="horizontal">

        <ImageView
            android:id="@+id/handle"
            android:layout_width="100dp"
            android:layout_height="500dp"
            android:src="@android:color/white" />

        <LinearLayout
            android:id="@id/content"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical">

        </LinearLayout>

    </SlidingDrawer>
</FrameLayout>