android - 如何使support.v4.widget.SlidingPaneLayout Pane 向左滑动

标签 android menu slide

我正在使用support.v4.widget.SlidingPaneLayout,我的应用支持两种语言:英语和阿拉伯语。支持的Android版本从4.2开始。

对于英语,我使用 SlidingPaneLayout 的默认行为,即。菜单位于左侧,内容框架从左到右打开。当用户选择阿拉伯语时。我希望一切都是从右到左 (RTL)。

请告诉我对 SlidingPaneLayout 的任何调整,以便在 1 个镜头中我可以将其设为 RTL,即。右侧的菜单和内容框架从右向左打开。

提前致谢。

http://developer.android.com/reference/android/support/v4/widget/SlidingPaneLayout.html

最佳答案

首先添加RTL支持

为了在您的应用中支持 RTL,您首先需要添加 android:supportsRtl="true"<application> list 文件中的元素。

在SlidingPanLayout中设置LTR

添加SlidingPaneLayout

  • android:layoutDirection="ltr"向左
  • android:layoutDirection="locale"由系统决定

示例:将SlidingPanelLayout设置在左侧

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/sliding_panel"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    android:layoutDirection="ltr"
    tools:context=".MainActivity"
    tools:showIn="@layout/app_bar_main">

    <fragment
        android:id="@+id/panel_left"
        android:name="onePanelFragment"
        android:layout_width="180dp"
        android:layout_height="match_parent"
        android:layout_gravity="start" />

    <fragment
        android:id="@+id/panel_right"
        android:name="twoPanelFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="end"
        android:layout_weight="1" />

</android.support.v4.widget.SlidingPaneLayout>

remember that the components inside the SliderLayout will also affect their alignment

关于android - 如何使support.v4.widget.SlidingPaneLayout Pane 向左滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22929875/

相关文章:

html - 使用 -webkit-animation-play-state :paused; not working 暂停 CSS Slide

java - 在 PreferenceActivity 中显示其他 View (Android)

user-interface - 多按钮 GUI VBScript

css - 网站菜单可访问性(一个有效,一个无效)

javascript - 一排积木——点击一个,其余的滑出屏幕

android - 如何在android中实现类似Viber个人资料页面的幻灯片效果

android - 我可以直接从 calllog.calls 提供商处获取照片吗

安卓 GCM : How to detect registered canonical ids in my own server?

android - Angular 6 - 有条件地更改 HTML header 中元素的属性

css - 如何使垂直子菜单向右扩展