gpt4 book ai didi

Android 不会加载回纵向布局

转载 作者:行者123 更新时间:2023-11-29 16:06:00 24 4
gpt4 key购买 nike

我在文件 activity_fbapp.xml 中放置了以下代码 layout-port

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".ActivityFBapp" >

<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Portrait" />


</LinearLayout>

然后我将下面的代码放在 activity_fbapp.xml 文件中(相同的文件名)放在 layout-land

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
tools:context=".ActivityFBapp" >
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="Landscape" />

</LinearLayout>

这就是我的Activity:

public class ActivityFBapp extends FragmentActivity 
{
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fbapp);
}
}

我使用模拟器来测试应用。我将它置于纵向模式,按 Ctrl+F11 以在横向模式下更改方向,并且它起作用了。它加载横向布局。

但是当我再次按Ctrl+F11 恢复纵向时,它不会重新加载纵向布局。

我不知道为什么。我究竟做错了什么?有什么想法吗?

最佳答案

试试这个...

在mainfest中添加这一行:

 <activity android:name="Your Activity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" android:windowSoftInputMode="adjustPan"/>

关于Android 不会加载回纵向布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18379664/

24 4 0