android - 从右到左 Android 应用中的选项卡滑动方向

标签 android android-layout xamarin xamarin.android android-tabs

我有一个带有标签页的 Android 应用程序。我希望应用程序从右到左。
我将 android:supportsRtl="true"放在 list 文件中,并将一些元素更改为 android:layoutDirection="rtl"。

它将所有内容从右向左更改,这正是我想要的,只是它反转了选项卡中的滑动方向 - 当您向左滑动时,它会移动到左侧选项卡,而不是与滑动相反。我想将其更改为常规滑动。

这是我的代码:

<android.support.v4.widget.DrawerLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="right"
android:fitsSystemWindows="true"
android:id="@+id/drawer_layout">
<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layoutDirection="rtl">
    <include
        android:id="@+id/toolbar"
        android:gravity="right"
        layout="@layout/toolbar" />
    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/main_layout"
        android:layout_below="@id/toolbar">
        <com.refractored.PagerSlidingTabStrip
            android:id="@+id/tabs"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:textColor="#ecf0f1"
            app:pstsShouldExpand="true"/>

        <android.support.v4.view.ViewPager
            android:id="@+id/pager"
            android:layout_width="match_parent"
            android:layout_height="0dp"
            android:layout_weight="1"
            tools:context=".MainActivity" />
    </LinearLayout>
</RelativeLayout>
<android.support.design.widget.NavigationView
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:layout_gravity="start"
    android:id="@+id/nav_view"
    android:layoutDirection="rtl"
    app:headerLayout="@layout/header"
    app:menu="@menu/nav_menu" />
</android.support.v4.widget.DrawerLayout>

希望你能帮助我。

谢谢!

最佳答案

我补充说:

android:layoutDirection="ltr"TabLayout

android:layoutDirection="rtl"

它工作得很好

关于android - 从右到左 Android 应用中的选项卡滑动方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37196714/

相关文章:

java - 数据不良时显示信息

android - 有没有办法改变菜单项图标和文本的颜色?

Android 应用 TensorFlow Google Cloud ML

java - android:layout_weight 考虑 FrameLayout 中嵌入 ImageViewer 的大小

c# - 相当于 Xamarin Forms 的 Toast

安卓 : How to get the dirty(changed) properties

android - 资源 $NotFoundException : Resource is not a ColorStateList (color or path): } in android

android - 在 RelativeLayout 中旋转到 ImageView

visual-studio - 为什么安装 Wear OS Intel x86 Atom 系统镜像 v2 失败

android - “No system images installed for this target” Xamarin AVD 管理器