SlidingDrawer 在原始屏幕上移动

发布于 2024-12-29 06:18:38 字数 139 浏览 3 评论 0原文

我的应用程序包含一个屏幕,其中包含一个水平滑动抽屉。 当用户按下抽屉把手时,抽屉应“覆盖”整个屏幕。当它关闭时,“原始”屏幕应该会显示。 我已将抽屉定位在 FrameLayout 中,但手柄消失了。

可以怎样解决呢?

谢谢, 埃亚勒

My application contains a screen which contains a horizental SlidingDrawer.
When user perss on the drawer handle, the drawer should "cover" the whole screen. when it closed, the "original" screen should reveal.
I have located the drawer in a FrameLayout but the handle disappeared.

How it can resolved?

Thanks,
Eyal

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

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

发布评论

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

评论(1

厌味 2025-01-05 06:18:38

有趣的是,我不久前刚刚解决了这个问题。我花了一段时间,但经过一些谷歌搜索和测试后,我想出了这个:

基本上,我将整个布局放入“相对布局”中,然后在其中为主要内容创建一个“线性布局”。在“相对布局”内部但在“线性布局”外部,我放置了“SlidingDrawer”。我在下面的 xml 中显示了按钮和句柄。另外,我在“SlidingDrawer”中为内容创建了“线性布局”。

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

 ..stuff for the main screen

</LinearLayout>
<SlidingDrawer
    android:id="@+id/SlidingDrawer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:content="@+id/contentLayout"
    android:handle="@+id/slideHandleButton" >
    <Button
        android:id="@+id/slideHandleButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/list_background"
        android:padding="8dp"
        android:text="My App"
        android:textSize="7pt" >
    </Button>
    <LinearLayout>

        ...sliding drawing is at the bottom
    ...stuff in here will be in the sliding drawer

    </LinearLayout>
</SlidingDrawer>
</RelativeLayout>

在发布此内容之前,我刚刚使用此代码运行了我的测试应用程序并且它有效。如果您有任何疑问,请询问,我希望这会有所帮助。

在此处输入图像描述

Funny, I just solved this problem not to long ago. It took me a little while but after some Googling and testing I came up with this:

Basically I put my entire layout into a "Relative Layout" and then created a "Linear Layout" inside of that for the main stuff. Inside the "Relative Layout" but outside of the "Linear Layout" I put my "SlidingDrawer". I am showing the buttons and handle in the xml below. Also, I created a "Linear Layout" in my "SlidingDrawer" for content.

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

 ..stuff for the main screen

</LinearLayout>
<SlidingDrawer
    android:id="@+id/SlidingDrawer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:content="@+id/contentLayout"
    android:handle="@+id/slideHandleButton" >
    <Button
        android:id="@+id/slideHandleButton"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/list_background"
        android:padding="8dp"
        android:text="My App"
        android:textSize="7pt" >
    </Button>
    <LinearLayout>

        ...sliding drawing is at the bottom
    ...stuff in here will be in the sliding drawer

    </LinearLayout>
</SlidingDrawer>
</RelativeLayout>

Before posting this, I just ran my test application with this code and it works. If you have any questions, please ask and I hope this helps.

enter image description here

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