Apple M1芯片下Android Studio为何无法加载含FragmentContainerView的XML设计视图?
问题:FragmentContainerView导致Android Studio设计视图黑屏
所有XML文件均可正常加载,但包含FragmentContainerView元素的文件除外——注释该元素后问题即可解决。设计视图无报错但显示黑屏,点击视图任意位置可高亮对应代码行,说明元素实际存在但未在设计视图中显示。
设备与软件环境
- 设备:MacBook Pro(13英寸,M1,2020),16GB内存,macOS Monterey 12.6
- Android Studio版本:Dolphin | 2021.3.1 Patch 1
已尝试的无效解决措施
- 清理Android Studio缓存
- 调整vmoptions配置文件
- 检查并安装Android Studio最新更新
示例代码
<layout 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"> <androidx.coordinatorlayout.widget.CoordinatorLayout android:id="@+id/coordianatorLayout" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/newbackround" android:orientation="vertical"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:fontFamily="@font/roboto_bold" android:text="@{viewModel.communityGroupModel.refused.toString()}" android:textColor="@color/black1b1d20" android:textSize="@dimen/text_size_20" tools:text="27" /> <androidx.fragment.app.FragmentContainerView android:id="@+id/eventPostFragmentContainer" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="@dimen/margin_12" app:layout_behavior="@string/appbar_scrolling_view_behavior" /> </androidx.coordinatorlayout.widget.CoordinatorLayout> </layout>
内容的提问来源于stack exchange,提问作者Muhammad Akkad
相关产品推荐
相关产品推荐

