androidx AppBarLayout AppBar上边距问题

时间:2019-04-24 09:30:56

标签: android android-layout android-appbarlayout androidx appbar

为什么AppBar会上升?以及如何解决?

其他信息。

如果您先开始活动,然后立即执行此片段,则一切正常。

如果您先开始活动,然后先创建一些片段,然后再创建该片段,那么一切都会变糟。

enter image description here

image. Android Studio layout designer - OK

image. API 16 - OK

xml布局code is here.

UPD。

<style name="EcommerceToolbar" parent="Widget.MaterialComponents.Toolbar">
        <item name="android:theme">@style/ThemeOverlay.MaterialComponents.Dark.ActionBar</item>
        <item name="popupTheme">@style/ThemeOverlay.MaterialComponents.Light</item>
    </style>

2 个答案:

答案 0 :(得分:0)

尝试将属性layout_height"?attr/actionBarSize"更改为AppBarLayout

<com.google.android.material.appbar.AppBarLayout
       android:id="@+id/filter_list_appbar_layout"
       app:liftOnScroll="false"
       android:layout_width="match_parent"
       android:layout_height="?attr/actionBarSize"
       app:layout_constraintEnd_toEndOf="parent"
       app:layout_constraintStart_toStartOf="parent"
       app:layout_constraintTop_toTopOf="parent"
       >

答案 1 :(得分:0)

这是魔术。 创建(v21)样式并在其中添加:

<item name="android:fitsSystemWindows">true</item>
相关问题