为了在Android Studio中预览布局时能够查看片段内某个视图的内容,可以执行this:
<MainLayoutView 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">
<fragment
...
tools:layout="@layout/my_fragment_view"/>
</MainLayoutView>
但是,如果您从fragment
切换到androidx.fragment.app.FragmentContainerView
,此便捷的工具将停止工作,并且片段仅在预览屏幕上显示为空白。
在Android Studio的布局中预览FragmentContainerView
内的内容时,有什么方法可以显示?
答案 0 :(得分:0)
在Android Studio的布局中预览内容时,是否可以在FragmentContainerView中显示内容? ->我想不是。 我有这个:
<androidx.fragment.app.FragmentContainerView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:name="com.example.MyFragment"
android:tag="my_tag"></androidx.fragment.app.FragmentContainerView>