【问题标题】:scroll in DrawerLayout在 DrawerLayout 中滚动
【发布时间】:2015-04-03 11:31:21
【问题描述】:

我的幻灯片菜单完美无缺,但是当我想滚动幻灯片菜单时却无法滚动。我在列表视图中有足够的项目可以滚动。如何在 DrawerLayout 中滚动? 滚动条显示,但我无能为力。我应该以编程方式添加它吗?

<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">
    <ScrollView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    <!-- Framelayout to display Fragments -->
    <FrameLayout
        android:id="@+id/frame_container"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />
    </ScrollView>
    <!-- Listview to display slider menu -->
    <ListView
        android:id="@+id/list_slidermenu"
        android:layout_width="240dp"
        android:layout_height="match_parent"
        android:layout_gravity="start"
        android:choiceMode="singleChoice"
        android:divider="@color/list_divider"
        android:dividerHeight="1dp"
        android:listSelector="@drawable/list_selector"
        android:background="@color/list_background"
     />

    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <Button
            android:id="@+id/btn_pick"
            android:layout_width="90dp"
            android:layout_height="55dp"
            android:layout_alignParentBottom="true"
            android:text="pick" />
        <Button
            android:id="@+id/sticker"
            android:layout_width="90dp"
            android:layout_height="55dp"
            android:text="add sticker"
            android:layout_below="@+id/paint_view"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true" />
        <Button
            android:id="@+id/save"
            android:layout_width="90dp"
            android:layout_height="55dp"
            android:text="save"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true" />
    <in.wptrafficanalyzer.graphicspickimageviewcanvas.PaintView
        android:id="@+id/paint_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_above="@id/btn_pick" />
    </RelativeLayout>
</android.support.v4.widget.DrawerLayout>

【问题讨论】:

  • 首先从布局中删除滚动视图,其次你走错了轨道找到抽屉布局的例子先了解然后尝试你自己
  • 这里滚动视图的目的是什么?
  • 滚动视图内的列表视图?
  • 移除滚动视图,列表视图具有滚动功能。

标签: android scrollview android-scrollview drawerlayout


【解决方案1】:

您需要将其他小部件放入框架布局中,试试这个,

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

<FrameLayout
    android:id="@+id/frame_container"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

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

        <Button
            android:id="@+id/btn_pick"
            android:layout_width="90dp"
            android:layout_height="55dp"
            android:layout_alignParentBottom="true"
            android:text="pick" />

        <Button
            android:id="@+id/sticker"
            android:layout_width="90dp"
            android:layout_height="55dp"
            android:text="add sticker"
            android:layout_below="@+id/paint_view"
            android:layout_alignParentRight="true"
            android:layout_alignParentEnd="true" />
        <Button
            android:id="@+id/save"
            android:layout_width="90dp"
            android:layout_height="55dp"
            android:text="save"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true" />
        <in.wptrafficanalyzer.graphicspickimageviewcanvas.PaintView
            android:id="@+id/paint_view"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_above="@id/btn_pick" />
    </RelativeLayout>

</FrameLayout>

<ListView
    android:id="@+id/list_slidermenu"
    android:layout_width="240dp"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:choiceMode="singleChoice"
    android:divider="@color/list_divider"
    android:dividerHeight="1dp"
    android:listSelector="@drawable/list_selector"
    android:background="@color/list_background"
 />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-04
    • 1970-01-01
    • 2013-06-01
    相关资源
    最近更新 更多