Android:有没有办法正确地将 SlidingDrawer 宽度和高度设置为半屏?

发布于 2024-10-15 22:01:40 字数 2677 浏览 3 评论 0原文

我必须在右侧设置一个 SlidingDrawer,并且单击时它不应扩展到半个屏幕。我看到了很多教程,我设法或多或少正确地设置了它,但它目前将布局中的所有内容都推到了左边。这是我的 xml:

<LinearLayout android:layout_height="wrap_content"
    android:id="@+id/edition_content_linear" android:layout_width="fill_parent"
    android:layout_weight="1" android:background="@android:color/white">

    <LinearLayout android:layout_width="fill_parent"
        android:id="@+id/static_menu_layout" android:layout_height="fill_parent"
        android:layout_weight="2" android:visibility="gone" android:background="@drawable/ipad_category_back">

        <ExpandableListView android:id="@+id/static_expandable_list"
            android:layout_height="fill_parent" android:layout_width="fill_parent"
            android:drawSelectorOnTop="false" android:groupIndicator="@drawable/expandablelist_selector" android:indicatorLeft="210dp" android:indicatorRight="230dp"></ExpandableListView>

    </LinearLayout>

    <LinearLayout android:id="@+id/center_linear"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:layout_weight="1">

        <ImageView android:scaleType="centerInside"
            android:layout_height="fill_parent" android:layout_width="fill_parent"
            android:id="@+id/cover_image_big"></ImageView>

        <WebView android:id="@+id/story_webview"
            android:layout_height="fill_parent" android:layout_width="fill_parent"
            android:visibility="gone"></WebView>

    </LinearLayout>

    <SlidingDrawer android:id="@+id/slider_drawer"
    android:layout_width="250dp" android:layout_height="500dp"
    android:orientation="horizontal" android:layout_gravity="center_vertical"
    android:handle="@+id/slider_handle" android:content="@+id/slider_expandable_list_container">

    <ImageView android:id="@+id/slider_handle"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:src="@drawable/menu_handler" />

    <RelativeLayout android:id="@+id/slider_expandable_list_container"
        android:layout_height="500dp" android:layout_width="250dp">
        <ExpandableListView android:id="@+id/slider_expandable_list"
            android:layout_height="fill_parent" android:layout_width="fill_parent"
            android:drawSelectorOnTop="false" android:indicatorLeft="210dp" android:layout_gravity="center_vertical"
            android:indicatorRight="230dp" android:groupIndicator="@drawable/expandablelist_selector"></ExpandableListView>

    </RelativeLayout>

   </SlidingDrawer>

</LinearLayout>

I have to set a SlidingDrawer on the right side and on click it should not expand over the half screen. I saw many tutos and i managed to set it more or less correctly but it's currently pushing everything in the layout to the left. Here is my xml:

<LinearLayout android:layout_height="wrap_content"
    android:id="@+id/edition_content_linear" android:layout_width="fill_parent"
    android:layout_weight="1" android:background="@android:color/white">

    <LinearLayout android:layout_width="fill_parent"
        android:id="@+id/static_menu_layout" android:layout_height="fill_parent"
        android:layout_weight="2" android:visibility="gone" android:background="@drawable/ipad_category_back">

        <ExpandableListView android:id="@+id/static_expandable_list"
            android:layout_height="fill_parent" android:layout_width="fill_parent"
            android:drawSelectorOnTop="false" android:groupIndicator="@drawable/expandablelist_selector" android:indicatorLeft="210dp" android:indicatorRight="230dp"></ExpandableListView>

    </LinearLayout>

    <LinearLayout android:id="@+id/center_linear"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:layout_weight="1">

        <ImageView android:scaleType="centerInside"
            android:layout_height="fill_parent" android:layout_width="fill_parent"
            android:id="@+id/cover_image_big"></ImageView>

        <WebView android:id="@+id/story_webview"
            android:layout_height="fill_parent" android:layout_width="fill_parent"
            android:visibility="gone"></WebView>

    </LinearLayout>

    <SlidingDrawer android:id="@+id/slider_drawer"
    android:layout_width="250dp" android:layout_height="500dp"
    android:orientation="horizontal" android:layout_gravity="center_vertical"
    android:handle="@+id/slider_handle" android:content="@+id/slider_expandable_list_container">

    <ImageView android:id="@+id/slider_handle"
        android:layout_width="wrap_content" android:layout_height="wrap_content"
        android:src="@drawable/menu_handler" />

    <RelativeLayout android:id="@+id/slider_expandable_list_container"
        android:layout_height="500dp" android:layout_width="250dp">
        <ExpandableListView android:id="@+id/slider_expandable_list"
            android:layout_height="fill_parent" android:layout_width="fill_parent"
            android:drawSelectorOnTop="false" android:indicatorLeft="210dp" android:layout_gravity="center_vertical"
            android:indicatorRight="230dp" android:groupIndicator="@drawable/expandablelist_selector"></ExpandableListView>

    </RelativeLayout>

   </SlidingDrawer>

</LinearLayout>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魔法少女 2024-10-22 22:01:40

将滑动抽屉放在框架布局中总是更好。因为在 Framelayout 中,视图将一个接一个地绘制。即使你的抽屉打开,它也会重叠在下面的视图上。但请注意,在框架布局中,抽屉会扩展到所有框架布局长度。如果你想限制抽屉的展开长度,那么给你的父框架布局一个长度。

Its always better to put the sliding drawer in a frame layout. Because in Framelayout, views will be drawn one on the other. Then even even you drawer opens up it 'll be overlapped on the views beneath. But note that in Framelayout drawer expands up to all the framelayout length. If you want to limit the length of expansion of the drawer, then give a length to your parent framelayout.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文