Shoshi
Shoshi

Reputation: 2254

SlidingDrawer shows up too far from bottom when it is close and it doesn't overlap view when it is open

this is my xml file:

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

<ScrollView
        xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:facebook="http://schemas.android.com/apk/res-auto"
        android:layout_width="fill_parent"
    android:layout_height="fill_parent"
        android:background="#FFF">

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:gravity="center">

        .................................
        .................................

        <SlidingDrawer
        android:layout_width="fill_parent"
        android:id="@+id/SlidingDrawer"
        android:handle="@+id/slideButton"
        android:content="@+id/contentLayout"
        android:padding="10dp"
        android:layout_height="150dp">

            <Button android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/slideButton"
                android:background="@drawable/action_eating">
            </Button>
            <LinearLayout
                android:layout_width="fill_parent"
                android:id="@+id/contentLayout"
                android:orientation="vertical"
                android:gravity="center"
                android:padding="10dp"
                android:background="#45454F"
                android:layout_height="wrap_content">
            <Button
            android:id="@+id/history"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/history"
            android:textColor="#000000"
            android:textSize="20sp" />
        </LinearLayout>
    </SlidingDrawer>

    </LinearLayout>    

</ScrollView>

the problem is, the SlidingDrawer remain in the bottom of my layout(that's fine), but it remain too far in the bottom (i think it remain 150dp bellow my layout). and when i click on it, it open but does not roll over on my layout, it remain under all my content i have shown in my layout. but i need to, when i click on it, slide it over my view. and when it closed it should remain just bellow of my layout, not too far from my layout (like 150dp).

sorry for my bad english. if you have any problem to understand what i have said, please let me know. thank you.

Upvotes: 1

Views: 997

Answers (2)

Shoshi
Shoshi

Reputation: 2254

i have found it. this is what i have done:

first of all, i have use <RelativeLayout> as parent. and under this parent i have used <ScrollView>. then i have remove the <SlidingDrawer> from <ScrollView> and paste it under the <ScrollView> but in <RelativeLayout>. but after that when i tap on the drawer button, it open but cover the whole screen which i don't want. i just want wrap_content. so i have used:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:orientation="vertical" 
    android:background="#FFF"
    android:gravity="bottom"
    android:layout_gravity="bottom">
<SrollView .....>
    .............................
    .............................
</ScrollView>

<SlidingDrawer
    android:layout_width="wrap_content"
    android:id="@+id/SlidingDrawer"
    android:handle="@+id/slideButton"
    android:content="@+id/contentLayout"
    android:layout_height="95dp"
    android:orientation="vertical"
    android:layout_alignParentBottom="true">

    ..................
    ..................

</SlidingDrawer>
</RelativeLayout>

Upvotes: 0

Veaceslav Gaidarji
Veaceslav Gaidarji

Reputation: 4311

Put your LinearLayout with content and SlidingDrawer into RelativeLayout

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

<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:facebook="http://schemas.android.com/apk/res-auto"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:background="#FFF">
<RelativeLayout
android:layout_width="fill_parent"
        android:layout_height="fill_parent">

<LinearLayout
android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:gravity="center">

        // your content
</LinearLayout>

<SlidingDrawer
android:layout_width="fill_parent"
        android:id="@+id/SlidingDrawer"
        android:handle="@+id/slideButton"
        android:content="@+id/contentLayout"
        android:padding="10dp"
        android:layout_height="150dp">

<Button android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/slideButton"
        android:background="@drawable/action_eating">
</Button>
<LinearLayout
android:layout_width="fill_parent"
        android:id="@+id/contentLayout"
        android:orientation="vertical"
        android:gravity="center"
        android:padding="10dp"
        android:background="#45454F"
        android:layout_height="wrap_content">
<Button
android:id="@+id/history"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/history"
        android:textColor="#000000"
        android:textSize="20sp" />
</LinearLayout>
</SlidingDrawer>

</RelativeLayout>

</ScrollView>

Upvotes: 1

Related Questions