我正在使用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/