按下时状态和应用栏之间的差距

时间:2018-08-21 17:53:09

标签: android kotlin android-jetpack

当我加载我的应用程序时,它看起来很好,如下所示: enter image description here

但是,当我轻按ListItem并按返回按钮时,将显示一个间隙,如下所示:

enter image description here

不确定是什么原因造成的:

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">

    <LinearLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:fitsSystemWindows="true">

        <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="0dp"/>
        </android.support.design.widget.AppBarLayout>

        <fragment
            android:id="@+id/car_nav_fragment"
            android:name="androidx.navigation.fragment.NavHostFragment"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:defaultNavHost="true"
            app:navGraph="@navigation/nav_transport" />

    </LinearLayout>

</layout>

我正在使用Android JetPack的导航控制器

nav_transport.xml

<?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"
    app:startDestination="@+id/car_list_fragment">

    <fragment
        android:id="@+id/car_list_fragment"
        android:name="com.example.transportdirectory.fragments.CarListFragment"
        android:label="@string/cars_title"
        tools:layout="@layout/fragment_car_list">

        <action
            android:id="@+id/action_car_list_fragment_to_car_detail_fragment"
            app:destination="@id/car_detail_fragment"
            app:enterAnim="@anim/slide_in_right"
            app:exitAnim="@anim/slide_out_left"
            app:popEnterAnim="@anim/slide_in_left"
            app:popExitAnim="@anim/slide_out_right" />
    </fragment>

    <fragment
        android:id="@+id/car_detail_fragment"
        android:name="com.example.transportdirectory.fragments.CarDetailFragment"
        android:label="@string/car_detail"
        tools:layout="@layout/fragment_car_detail">
        <argument
            android:name="vin"
            app:argType="string" />
    </fragment>

</navigation>

这就是我调用导航的方式

val direction = CarListFragmentDirections.ActionCarListFragmentToCarDetailFragment(vin)
            it.findNavController().navigate(direction)

0 个答案:

没有答案