Java 最小化活动后如何保持吐司方向?
手机始终处于横向模式 我的活动处于横向模式(并且有横向版本),它显示一个祝酒词,该祝酒词也在横向模式下显示。 在祝酒之后,我尽量减少活动:Java 最小化活动后如何保持吐司方向?,java,android,toast,landscape,Java,Android,Toast,Landscape,手机始终处于横向模式 我的活动处于横向模式(并且有横向版本),它显示一个祝酒词,该祝酒词也在横向模式下显示。 在祝酒之后,我尽量减少活动: Toast.makeText(getApplicationContext(), "My Toast Message", Toast.LENGTH_LONG).show(); moveTaskToBack(true); 土司会继续显示,但现在会在纵向模式下旋转90度(这可能与主屏幕的模式有关) 到目前为止,我只找到了这个 有没有办法强制以
Toast.makeText(getApplicationContext(), "My Toast Message", Toast.LENGTH_LONG).show();
moveTaskToBack(true);
土司会继续显示,但现在会在纵向模式下旋转90度(这可能与主屏幕的模式有关)
到目前为止,我只找到了这个
有没有办法强制以横向模式显示土司?(toast是在横向模式下启动的,因此它不应该旋转90度,而应该保持横向模式)
我想要的是:当我按下一个按钮时,活动消失(然后我们会看到任何应用程序或主屏幕),并显示祝酒词。全部处于横向模式。这有可能吗?我找到了一种简便易行的方法来实现这一点 首先,我试着用一段时间来展示祝酒词和移动任务包。但这并不奏效。moveTaskToBack比计时器更强大,当手机仍处于横向模式时,toast继续以纵向模式显示 然后我考虑调整imageView。如果可以旋转90度来显示它呢?这就是解决办法。它起作用了 在布局中,将以下线条添加到imageview(或任何其他元素)以将其旋转90度:
android:rotation="90"
然后,你必须播放和测试你的手机,将你的元素(不仅是图像视图,还有按钮、文本视图等)定位到你想在屏幕上显示的位置
我用过:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00FFFFFF"
android:backgroundTint="#00FFFFFF"
android:orientation="horizontal">
<TextView
android:id="@+id/texttoast"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="430dp"
android:layout_toStartOf="@id/imagetoast"
android:rotation="90"
android:text="My text here"
android:textAlignment="center"
android:textColor="#000000" />
<ImageView
android:id="@+id/imagetoast"
android:layout_width="190dp"
android:layout_height="190dp"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="15dp"
android:rotation="90"
android:src="@drawable/my_image" />
</RelativeLayout>
我找到了一种简便易行的方法来实现这一点 首先,我试着用一段时间来展示祝酒词和移动任务包。但这并不奏效。moveTaskToBack比计时器更强大,当手机仍处于横向模式时,toast继续以纵向模式显示 然后我考虑调整imageView。如果可以旋转90度来显示它呢?这就是解决办法。它起作用了 在布局中,将以下线条添加到imageview(或任何其他元素)以将其旋转90度:
android:rotation="90"
然后,你必须播放和测试你的手机,将你的元素(不仅是图像视图,还有按钮、文本视图等)定位到你想在屏幕上显示的位置
我用过:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00FFFFFF"
android:backgroundTint="#00FFFFFF"
android:orientation="horizontal">
<TextView
android:id="@+id/texttoast"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="430dp"
android:layout_toStartOf="@id/imagetoast"
android:rotation="90"
android:text="My text here"
android:textAlignment="center"
android:textColor="#000000" />
<ImageView
android:id="@+id/imagetoast"
android:layout_width="190dp"
android:layout_height="190dp"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="15dp"
android:rotation="90"
android:src="@drawable/my_image" />
</RelativeLayout>