Java Android Studio Emulator中的横向模式不工作?
以下示例来自项目,布局文件来自 我在Android Studio Emulator中使用纵向和横向模式对其进行了测试,您可以在A1.png和A2.png中看到结果 在Android Studio Emulator中,横向模式似乎不起作用 我在真实的手机上测试了相同的代码,你可以在B1.png和B2.png上看到结果 在真实手机中,横向模式运行良好,当我使用横向模式时,Android Studio Emulator有什么问题 顺便说一句,我读过这篇文章 navigation\u activity.xmlJava Android Studio Emulator中的横向模式不工作?,java,android,android-studio,android-emulator,Java,Android,Android Studio,Android Emulator,以下示例来自项目,布局文件来自 我在Android Studio Emulator中使用纵向和横向模式对其进行了测试,您可以在A1.png和A2.png中看到结果 在Android Studio Emulator中,横向模式似乎不起作用 我在真实的手机上测试了相同的代码,你可以在B1.png和B2.png上看到结果 在真实手机中,横向模式运行良好,当我使用横向模式时,Android Studio Emulator有什么问题 顺便说一句,我读过这篇文章 navigation\u activity.
<androidx.drawerlayout.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:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.android.codelabs.navigation.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar" />
<fragment
android:id="@+id/my_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation" />
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:menu="@menu/nav_drawer_menu" />
</androidx.drawerlayout.widget.DrawerLayout>
A2.png
B1.png
B2.png
添加内容
没有名字:谢谢
我顺便测试一下,Android Studio 3.5中带有横向模式的模拟器似乎还不能很好地工作
使用横向模式时,真实手机中的菜单图标不会显示在使用横向模式的模拟器中,您可以看到C1.png,为什么?B2.png是真正的手机,具有横向模式
C1.png
因为在emulator控件中单击“向左旋转/向右旋转”后,还需要在右下角的设备内部设置旋转
之前
之后
谢谢!你能看看我在问题中添加的内容吗?我能问一下为什么汉堡包风格“只在横向”吗?您是否将其添加到代码中?单击两个按钮旋转设备和屏幕有什么意义?
<LinearLayout
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:orientation="vertical"
tools:context="com.example.android.codelabs.navigation.MainActivity">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar" />
<fragment
android:id="@+id/my_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_nav_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:menu="@menu/bottom_nav_menu" />
</LinearLayout>
<RelativeLayout
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"
tools:context="com.example.android.codelabs.navigation.MainActivity">
<com.google.android.material.navigation.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
app:elevation="0dp"
app:headerLayout="@layout/nav_view_header"
app:menu="@menu/nav_drawer_menu" />
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_toEndOf="@id/nav_view"
android:background="?android:attr/listDivider" />
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toEndOf="@id/nav_view"
android:background="@color/colorPrimary"
android:theme="@style/ThemeOverlay.MaterialComponents.Dark.ActionBar" />
<fragment
android:id="@+id/my_nav_host_fragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/toolbar"
android:layout_toEndOf="@id/nav_view"
app:defaultNavHost="true"
app:navGraph="@navigation/mobile_navigation" />
</RelativeLayout>