当Fragment替换时,在Lollipop和更高版本的WindowTitleBar和Toolbar之间显示额外的填充

问题描述 投票:0回答:1

我无法删除工具栏上方的填充

但是在Lollipop设备下面没有这样的问题

activity_main.xml中

<?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"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:orientation="vertical">

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:background="?attr/colorPrimary"
            android:minHeight="?attr/actionBarSize"
            app:titleTextColor="@color/white" />

        <View
            android:layout_width="match_parent"
            android:layout_height="4dp"
            android:background="@xml/drop_shadow_bottom" />
    </LinearLayout>

    <FrameLayout
        android:id="@+id/container"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@id/header" />

</RelativeLayout>

next_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_margin="0dp"
    android:background="@color/white"
    android:fitsSystemWindows="true"
    android:orientation="vertical"
    android:padding="0dp">

    <LinearLayout
        android:id="@+id/view_textcontents"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/footer"
        android:layout_alignParentTop="true"
        android:orientation="vertical"
        android:padding="@dimen/margin_small">

        <android.support.v7.widget.AppCompatEditText
            android:id="@+id/aet_post_title"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/white"
            android:hint="@string/hint_post_title"
            android:inputType="text"
            android:padding="@dimen/margin_small"
            android:textAppearance="?android:attr/textAppearanceMedium">

            <requestFocus />
        </android.support.v7.widget.AppCompatEditText>

        <View
            android:layout_width="match_parent"
            android:layout_height="1dp"
            android:background="@color/light_grey" />

        <android.support.v7.widget.AppCompatEditText
            android:id="@+id/aet_post_desc"
            android:layout_width="match_parent"
            android:layout_height="fill_parent"
            android:background="@color/white"
            android:gravity="start"
            android:hint="@string/post_description"
            android:inputType="textLongMessage|textMultiLine"
            android:padding="@dimen/margin_small"
            android:textAppearance="?android:attr/textAppearanceSmall" />
    </LinearLayout>

</RelativeLayout>
android xml android-fragments android-actionbar
1个回答
0
投票

那么你可以摆脱它。如果你想在你的XML代码中,父元素应该有padding-bottom,up,right,left。虽然你还没有真正问过一个问题。我假设你问为什么会改变。你可以在以下链接找到谷歌发布的关于android应用程序设计的所有资料:google material design希望这会有所帮助

© www.soinside.com 2019 - 2024. All rights reserved.