android - recyclerview 或 viewpager 上的 setRotationY(180) 在 Android 9(API 28)中创建滚动问题
问题描述
我通过为 recyclerview 和 viewpagers 实现 setRotationY 来管理 RTL 内容,但它似乎只在具有 API 28 的设备中创建滚动/滑动问题,否则它工作得很好。如果我删除 setRotationY,它工作得很好。有没有人遇到过这个问题?如果是这样,如何解决?
PS:旋转 360f 不会影响滚动,但旋转 180f 会。
解决方案
由于 ViewPager.setRotatingY(180) 我在 API 28 上遇到了 ViewPager 的这个问题,所以我可以支持 RTL,我尝试用 layoutDirection="locale" 替换旋转,但它没有用。我找到了一个支持 RTL ViewPager 的库,这是一个链接https://github.com/duolingo/rtl-viewpager。
将其添加到依赖项并确保将 layoutDirection="locale" 添加到 RtlViewPager
<com.duolingo.open.rtlviewpager.RtlViewPager
android:layoutDirection="locale"
android:keepScreenOn="true"
android:id="@+id/quranViewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
/>
更新
ViewPager2 对区域设置友好,因此它会根据当前设备区域设置自动更改滑动方向。
有关 ViewPager2 实现的一些有用链接:
推荐阅读
- java - 如何修复android工具栏中的重复项,(需要删除工具栏上的菜单项)?
- google-kubernetes-engine - 无法从部署在 GKE 中的 ISTIO 访问 cassandra
- python-3.x - 努力将方法调用到另一个类
- git - Visual Studio Git 详细信息
- php - 在用户无法查看数据的情况下将 php 数据转换为 html
- python - 如何使用python在csv文件中写入包含逗号的列表?
- python - Python - 在函数之间使用变量
- delphi - 根据按钮的用途创建框架
- sql - 从列生成额外的 SQL 行
- google-app-engine - Google App Engine 标准环境中的 Gunicorn 命令行错误