android - 如何防止反向横向但在Android中允许横向?
问题描述
我有一个活动,我希望视图在所有情况下都位于设备的左侧(音量/电源按钮的对面)。
我在 Activity 的纵向和横向方向上执行此操作没有问题,但是当它进入反向横向和反向纵向时,视图将转到设备的右侧(音量/电源按钮侧)。
是否可以允许屏幕方向更改但阻止反向方向?
活动主.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CustomView
android:layout_width="150dp"
android:layout_height="wrap_content"
>
</CustomView>
<include
layout="@layout/some_layout"
>
</include>
</LinearLayout>
activity_main.xml(土地):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<CustomView
android:layout_width="wrap_content"
android:layout_height="150dp">
</CustomView>
<include layout="@layout/some_Other_layout" />
</LinearLayout>
我已经尝试了orientationListener,每当它进入反向横向时,我都会尝试将方向设置为横向,然后通过设置未指定来释放方向,但这不起作用,因为屏幕被锁定并且方向的进一步变化没有被检测到。
关于如何解决这个问题的任何想法?
解决方案
推荐阅读
- python - Pandas read_csv 有没有办法将 sqlachemy 数据类型转换为 pandas dtypes?
- javascript - 试图在 asp.net 中使用存储过程来插入数据,我错过了什么?
- python - OneToOneField Django的反向关系?
- python - 蝗虫中的“未命名模块”
- javascript - 在 AngularJS 中访问对象的参数
- qt - 将 FFMPEG 与 QT 一起使用
- python - 文件迭代。不能在 for 循环中使用浮点对象
- javascript - 有没有办法在 JavaScript 中创建整数范围?
- jsf - 目标无法到达,标识符“growT”解析为空
- arangodb - 从命令行运行 arangodb 文本文件