1

これは私のxmlファイルです:

<?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>

問題は、SlidingDrawerがレイアウトの下部に残っていることです(これで問題ありません)が、下部に留まりすぎています(レイアウトの下に150dpのままだと思います)。クリックすると開きますが、レイアウト上でロールオーバーせず、レイアウトに表示したすべてのコンテンツの下に残ります。しかし、私はそれをクリックするときに、それを私のビューの上にスライドさせる必要があります。そしてそれが閉じたとき、それは私のレイアウトのすぐ下にとどまり、私のレイアウトからそれほど遠くないはずです(150dpのように)。

私の悪い英語でごめんなさい。私が言ったことを理解するのに何か問題があれば、私に知らせてください。ありがとうございました。

4

2 に答える 2

1

LinearLayoutコンテンツを入れSlidingDrawerRelativeLayout

<?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>
于 2012-12-21T14:35:29.337 に答える
0

私はそれを見つけた。これは私がしたことです:

まず第一に、私は<RelativeLayout>親として使用しています。そしてこの親の下で私は使用し<ScrollView>ました。次に、を削除して<SlidingDrawer>、butの<ScrollView>下に貼り付けます。でもその後、引き出しボタンをタップすると開きますが、画面全体を覆ってしまいます。wrap_contentが欲しいだけです。だから私は使用しました:<ScrollView><RelativeLayout>

<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>
于 2012-12-22T13:10:02.550 に答える