Merge pull request #5100 from ByteHamster/fix-flickering

Fixed tab flickering
This commit is contained in:
ByteHamster 2021-04-10 11:01:16 +02:00 committed by GitHub
commit 2c4693b938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 36 additions and 25 deletions

View File

@ -6,24 +6,44 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<androidx.appcompat.widget.Toolbar <!--
While the same visuals could be achieved without this nested layout,
RelativeLayout invalidates all its direct children when the playback
position is updated. This causes flickering of the tabs every second.
-->
<LinearLayout
android:id="@+id/pagerContainer"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
app:navigationIcon="?homeAsUpIndicator" android:layout_above="@id/playtime_layout"
android:id="@+id/toolbar"/> android:orientation="vertical"
android:layout_marginBottom="12dp">
<com.google.android.material.tabs.TabLayout <androidx.appcompat.widget.Toolbar
android:id="@+id/sliding_tabs" android:layout_width="match_parent"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:layout_height="wrap_content" android:minHeight="?attr/actionBarSize"
android:layout_below="@id/toolbar" android:theme="?attr/actionBarTheme"
android:background="?android:attr/windowBackground" app:navigationIcon="?homeAsUpIndicator"
app:tabBackground="?attr/selectableItemBackground" android:id="@+id/toolbar"/>
app:tabMode="fixed"
app:tabGravity="fill"/> <com.google.android.material.tabs.TabLayout
android:id="@+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:attr/windowBackground"
app:tabBackground="?attr/selectableItemBackground"
app:tabMode="fixed"
app:tabGravity="fill"/>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:foreground="?android:windowContentOverlay"/>
</LinearLayout>
<FrameLayout <FrameLayout
android:id="@+id/playerFragment" android:id="@+id/playerFragment"
@ -34,19 +54,10 @@
tools:layout_height="@dimen/external_player_height" tools:layout_height="@dimen/external_player_height"
android:elevation="8dp"/> android:elevation="8dp"/>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_above="@id/playtime_layout"
android:layout_below="@id/sliding_tabs"
android:foreground="?android:windowContentOverlay"
android:layout_marginBottom="12dp"/>
<ImageView <ImageView
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="8dp" android:layout_height="8dp"
android:layout_alignBottom="@id/pager" android:layout_alignBottom="@id/pagerContainer"
android:src="@drawable/bg_gradient" android:src="@drawable/bg_gradient"
app:tint="?android:attr/windowBackground" app:tint="?android:attr/windowBackground"
android:importantForAccessibility="no"/> android:importantForAccessibility="no"/>
@ -56,7 +67,7 @@
android:alpha="0" android:alpha="0"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignBottom="@+id/pager" android:layout_alignBottom="@+id/pagerContainer"
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginBottom="12dp" android:layout_marginBottom="12dp"
app:cardCornerRadius="8dp" app:cardCornerRadius="8dp"