FragmentContainerView是否具有等效的“ tools:layout =“?

时间:2019-11-23 11:12:24

标签: android android-studio

为了在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内的内容时,有什么方法可以显示?

1 个答案:

答案 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>