material-components-android icon indicating copy to clipboard operation
material-components-android copied to clipboard

[TopAppBar] Compress effect not fully working on API levels <24

Open patrickfrei opened this issue 3 years ago • 0 comments
trafficstars

Description: I've see that the compress effect of the M3 catalog example "Top App Bar - Compress Effect Demo" (TopAppBarCompressEffectFragment) is not properly working on devices with API levels <24. The problem occurs in case tabs are used: When scrolling up, the app bar title is being compressed and disappears as intended. However, as soon as the tabs are starting to get hidden, the app bar title reappears and overlaps with the tab icons and text. If you remove app:layout_scrollEffect="compress" from the XML, the issue disappears (but of course also the compress effect). See the following animation: https://github.com/patrickfrei/test_coding/blob/main/compress_effect.webm

Expected behavior:

  1. The compress effect also works as intended on API levels <24, i.e. the app bar title and tab text / icons do not overlap when scrolling up / down.
  2. In addition, it would be great to have a possiblity to set the scroll effect programmatically. See feature request #2894 .

Source code: <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" style="?attr/catalogToolbarWithCloseButtonStyle" android:layout_width="match_parent" android:layout_height="wrap_content" app:layout_scrollFlags="scroll|enterAlways|snap" app:layout_scrollEffect="compress" app:title="@string/cat_topappbar_compress_toolbar_title" />

Minimal sample app repro: See M3 catalog example "Top App Bar - Compress Effect Demo":

  1. https://github.com/material-components/material-components-android/blob/master/catalog/java/io/material/catalog/topappbar/TopAppBarCompressEffectFragment.java
  2. https://github.com/material-components/material-components-android/blob/master/catalog/java/io/material/catalog/topappbar/res/layout/cat_topappbar_compress_effect_fragment.xml

Android API version: API 23, 22, 21... 16

Material Library version: 1.7.0-beta01

Device: Pixel 5 emulator

patrickfrei avatar Aug 02 '22 21:08 patrickfrei