当使用导航架构组件Android导航到目标片段时,屏幕为白色
我使用导航图从片段a导航到片段B,动画向上滑动持续时间=0.4s,但是在片段B出现之前0.4s,片段a变成白色屏幕,而不是之前保留状态数据和UI 更新: 我尝试在所有屏幕上克隆一个带有背景色配置的示例项目。我发现当导航到片段B时,片段A被删除并替换为片段B,因此在0.4s期间,包含片段的主活动布局可以通过其背景色看到 activity_main.xml当使用导航架构组件Android导航到目标片段时,屏幕为白色,android,android-fragments,android-architecture-navigation,Android,Android Fragments,Android Architecture Navigation,我使用导航图从片段a导航到片段B,动画向上滑动持续时间=0.4s,但是在片段B出现之前0.4s,片段a变成白色屏幕,而不是之前保留状态数据和UI 更新: 我尝试在所有屏幕上克隆一个带有背景色配置的示例项目。我发现当导航到片段B时,片段A被删除并替换为片段B,因此在0.4s期间,包含片段的主活动布局可以通过其背景色看到 activity_main.xml <?xml version="1.0" encoding="utf-8"?> <android.support.constra
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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:background="#F1E78C"
tools:context="com.myricseptember.countryfact.ui.MainActivity">
<fragment
android:id="@+id/navigationHostFragment"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:defaultNavHost="true"
app:navGraph="@navigation/countryfact_navigation_graph"/>
</android.support.constraint.ConstraintLayout>
=>如何自定义导航添加片段(而不是删除替换)或自定义句柄在片段B事务启动后删除A?我通过添加配置修复了白色屏幕:app:enterAnim=“@anim/slide\u up”app:exitAnim=“@anim/no\u anim”app:popeneranim=“@anim/no\u anim”app:popExitAnim=“@anim/slide\u down”
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="#123456">
<android.support.v7.widget.RecyclerView
android:id="@+id/countryRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:layoutManager="android.support.v7.widget.LinearLayoutManager"
tools:listitem="@layout/layout_list_item" />
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:background="#CAEACB">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.constraint.ConstraintLayout>
</ScrollView>
<?xml version="1.0" encoding="utf-8"?>
<navigation 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/countryfact_navigation_graph"
app:startDestination="@id/countryListFragment">
<fragment
android:id="@+id/countryListFragment"
android:name="com.myricseptember.countryfact.ui.list.CountryListFragment"
android:label="Country Fact"
tools:layout="@layout/fragment_country_list">
<action
android:id="@+id/action_countryListFragment_to_countryDetailsFragment"
app:destination="@id/countryDetailsFragment"
app:enterAnim="@anim/slide_up"
app:popExitAnim="@anim/slide_down" />
</fragment>
<fragment
android:id="@+id/countryDetailsFragment"
android:name="com.myricseptember.countryfact.ui.details.CountryDetailsFragment"
android:label="CountryDetailsFragment"
tools:layout="@layout/fragment_country_details" />
/>
</navigation>