androidx AppBarLayout AppBar上边距问题

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

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

附加信息。

如果你开始活动,然后立即开始这个片段,那么一切都OK。

如果你开始活动,然后是一些片段,然后是这个片段,那么一切都很糟糕。

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>
android android-layout android-appbarlayout androidx appbar
2个回答
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"
       >

0
投票

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

<item name="android:fitsSystemWindows">true</item>
© www.soinside.com 2019 - 2024. All rights reserved.