如何让Android SlidingDrawer从左侧滑出?

发布于 2024-07-27 14:55:39 字数 481 浏览 10 评论 0原文

我在应用程序中使用 slidingDrawer ,在纵向模式下,其处理程序位于底部。 当用户切换到横向模式(宽屏)时,我希望处理程序位于左侧。 当我将方向从垂直更改为水平时,处理程序放置在右侧。

我已经像这样定义了我的布局 XML:

<SlidingDrawer
    android:id="@+id/l_drawer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:handle="@+id/l_handle"
    android:content="@+id/l_content"
    android:orientation="horizontal"
    android:layout_gravity="left"
    >

有人知道如何使其从左向右滑动吗?

I'm using a slidingDrawer in my application that has its handler placed at the bottom when in portrait mode. When the user switches to landscape mode (widescreen) I would like to have the handler located on the left. When I change the orientation from vertical to horizontal, the handler is placed on the right.

I have defined my layout XML like this:

<SlidingDrawer
    android:id="@+id/l_drawer"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:handle="@+id/l_handle"
    android:content="@+id/l_content"
    android:orientation="horizontal"
    android:layout_gravity="left"
    >

Anyone have an idea for how to make it slide from left to right ?

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

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

发布评论

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

评论(4

失与倦" 2024-08-03 14:55:41

我认为您不能,除非获取 SlidingDrawer 源代码,对其进行更改并使用修改后的版本。 同样,您无法制作从顶部下降的 SlidingDrawer

I don't think you can, other than perhaps by grabbing the SlidingDrawer source code, making changes to it, and using your modified version. You similarly cannot make a SlidingDrawer that descends from the top.

飘然心甜 2024-08-03 14:55:41

我已经为此重写了一个类,并将其作为我的开源库的一部分。 我花了将近一周的时间才把它做好。 请在 Android 的 Aniqroid 开源库中查看我的 SlidingTray

http://aniqroid.sileria.com/doc/api

查找下载链接和文档上面链接中的 SlidingTray 类。

(披露:我是该项目的维护者。)

I have rewritten a class to that and made it part of my open source library. It took me almost a week to get it right. Please check out my SlidingTray in Aniqroid open source library for Android.

http://aniqroid.sileria.com/doc/api

Find the download link and the documentation for SlidingTray class in the above link.

(Disclosure: I am the maintainer of the project.)

无声无音无过去 2024-08-03 14:55:41

您可以使用此答案中发布的代码:Android SlidingDrawer from top?

提供的解决方案功能在 xml 中设置 Slidingdrawer 的方向,而且很简单,只需要 1 个类和 attrs.xml 中的一些添加,并且稳定,因为它源自 SDK 的 Android Slidingdrawer。 我还讨论了为什么我没有选择在互联网/SO 上找到的其他流行的库/解决方案。

要点快速链接:MultipleOrientationSlidingDrawer(源代码和示例)@ gist

You can use the code posted in this answer: Android SlidingDrawer from top?

The provided solution features setting the orientation of the Slidingdrawer in xml also it's simple requiring only 1 class and some additions in attrs.xml and stable since it's derived from Androids Slidingdrawer from SDK. I also discuss why I didn't choose other popular libs/solutions found on the internet/SO.

Quicklink to the gist: MultipleOrientationSlidingDrawer (source & example) @ gist

浮萍、无处依 2024-08-03 14:55:40

我找到了一个简单的方法来做到这一点。 您所要做的就是为slidingDrawer、内容和手柄设置180° 的旋转。
您可以类似地制作一个从顶部下降的 SlidingDrawer,就像我所做的 这里

看看我这里的例子,首先从右到左,以便能够看到差异。

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/slidingDrawer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_horizontal"
    android:handle="@+id/handle"
    android:content="@+id/content">
    <ImageView android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />
    <ImageView android:id="@+id/content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:src="@drawable/ic_launcher" />
</SlidingDrawer>

现在看看我做了什么改变,让它从左边滑出。

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/slidingDrawer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_horizontal"
    android:handle="@+id/handle"
    android:content="@+id/content"
    android:rotation="180">
    <LinearLayout android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <ImageView android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            android:rotation="180" />
    </LinearLayout>
    <ImageView android:id="@+id/content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:src="@drawable/ic_launcher"
        android:rotation="180" />
</SlidingDrawer>

请注意,我还创建了一个 LinearLayout 来设置为句柄,并且没有更改它的旋转,但我更改了它的子级的旋转。 这是为了防止我遇到一个小问题,但一切都工作正常而且很简单。

I've found a simple way to do that. All you have to do is to set the rotation of 180º for the slidingDrawer, the content and the handle.
You can similarly make a SlidingDrawer that descends from the top, like I did here.

Look at my examples here, first from right to left, to be able to see the differences.

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/slidingDrawer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_horizontal"
    android:handle="@+id/handle"
    android:content="@+id/content">
    <ImageView android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_launcher" />
    <ImageView android:id="@+id/content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:src="@drawable/ic_launcher" />
</SlidingDrawer>

Now look what I changed to make it sliding out from the left.

<SlidingDrawer xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/slidingDrawer"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:gravity="center_horizontal"
    android:handle="@+id/handle"
    android:content="@+id/content"
    android:rotation="180">
    <LinearLayout android:id="@+id/handle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
        <ImageView android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            android:rotation="180" />
    </LinearLayout>
    <ImageView android:id="@+id/content"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="#FF0000"
        android:src="@drawable/ic_launcher"
        android:rotation="180" />
</SlidingDrawer>

Note that I also created a LinearLayout to set as handle, and didn't change it's rotation, but I changed the rotation of it's child. This was to prevent a small issue I had, but everything is working fine and it's simple.

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