0

我想要一个滑动抽屉,它显示在我的视图底部,但它目前没有显示。我还尝试使用线性布局作为根,滚动视图的权重为 1,但这会导致滚动视图及其内容不显示。有任何想法吗?

我的观点:

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

<ScrollView
    android:id="@+id/scrollLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        tools:context=".AddScheduleItemActivity" >

        .
        .
        .

    </LinearLayout>
</ScrollView>

<SlidingDrawer
    android:id="@+id/slidingDrawer1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/scrollLayout"
    android:content="@+id/content"
    android:handle="@+id/handle" >

    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Handle" />

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/hadsfndle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="sdf" />
    </LinearLayout>
</SlidingDrawer>

谢谢,内森

它应该是什么样子

在图片中,我希望蓝色是滚动视图和内容,绿色是滑块的句柄。

尝试遵循其他一些建议,但仍然无法正常工作。滚动视图的内容显示正常,但未显示滑块。需要更多建议!谢谢!

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/scrollLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        .
        .
        .

    </RelativeLayout>
</ScrollView>

<SlidingDrawer
    android:id="@+id/slidingDrawer1"
    android:layout_width="match_parent"
    android:layout_height="50dip"
    android:layout_alignParentBottom="true"
    android:layout_below="@+id/scrollLayout"
    android:content="@+id/content"
    android:handle="@+id/handle"
    android:orientation="vertical" >

    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Handle" />

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/hadsfndle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="sdf" />
    </LinearLayout>
</SlidingDrawer>

</RelativeLayout>

好吧,似乎不再支持滑动抽屉,所以我想我会寻找替代方案:(

4

3 回答 3

1

您正在尝试在底部显示您的滑块,请尝试以下代码:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" 
    >

    <ScrollView
        android:id="@+id/scrollLayout"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <LinearLayout
            android:id="@+id/layout"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >


        </LinearLayout>
    </ScrollView>

    <LinearLayout
        android:id="@+id/LinearLayout01"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/layout"
        android:orientation="vertical" >

        <SlidingDrawer
            android:id="@+id/SlidingDrawer"
            android:layout_width="wrap_content"
            android:layout_height="250dip"
            android:content="@+id/contentLayout"
            android:handle="@+id/slideHandleButton"
            android:padding="10dip" >

            <Button
                android:id="@+id/slideHandleButton"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="@drawable/ic_launcher" >
            </Button>

            <LinearLayout
                android:id="@+id/contentLayout"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:background="#C0C0C0"
                android:gravity="center|top"
                android:orientation="vertical"
                android:padding="10dip" >

                <Button
                    android:id="@+id/Button01"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Content" >
                </Button>

                <Button
                    android:id="@+id/Button02"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Content" >
                </Button>

                <Button
                    android:id="@+id/Button03"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Content" >
                </Button>
            </LinearLayout>
        </SlidingDrawer>
    </LinearLayout>

</RelativeLayout>

如果上面的代码不能解决你的问题,那么改变父布局LinearLayoutweightsum=10然后在你之间分配scrollview & sliderDrawer相等。

于 2013-02-05T05:16:37.293 回答
0

Try this,

Add layout_alignParentBottom on your SlidingDrawer.

 android:layout_alignParentBottom="true"
于 2013-02-05T04:39:25.387 回答
0

也许您的问题已经在这里得到了回答。

尝试这个:

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

<ScrollView
    android:id="@+id/scrollLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        .
        .
        .

    </RelativeLayout>
</ScrollView>

<SlidingDrawer
    android:id="@+id/slidingDrawer1"
    android:layout_width="match_parent"
    android:layout_height="50dip"
    android:layout_alignParentBottom="true"
    android:content="@+id/content"
    android:handle="@+id/handle"
    android:orientation="vertical" >

    <Button
        android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Handle" />

    <LinearLayout
        android:id="@+id/content"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <Button
            android:id="@+id/hadsfndle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="sdf" />
    </LinearLayout>
</SlidingDrawer>

</RelativeLayout>
于 2015-01-07T16:59:48.467 回答