Use some animations in sheet toolbar
This commit is contained in:
committed by
Koitharu
parent
73498964a8
commit
6dc8a4ffb5
@@ -0,0 +1,22 @@
|
|||||||
|
package org.koitharu.kotatsu.base.ui.widgets
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.graphics.drawable.Drawable
|
||||||
|
import android.util.AttributeSet
|
||||||
|
import android.view.View
|
||||||
|
import androidx.appcompat.widget.Toolbar
|
||||||
|
import androidx.core.view.isGone
|
||||||
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
|
|
||||||
|
class AnimatedToolbar(context: Context, attrs: AttributeSet?) : MaterialToolbar(context, attrs) {
|
||||||
|
companion object {
|
||||||
|
private val navButtonViewField = Toolbar::class.java.getDeclaredField("mNavButtonView")
|
||||||
|
.also { it.isAccessible = true }
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun setNavigationIcon(icon: Drawable?) {
|
||||||
|
super.setNavigationIcon(icon)
|
||||||
|
|
||||||
|
(navButtonViewField.get(this) as? View)?.isGone = (icon == null)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout
|
<androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
@@ -14,11 +14,12 @@
|
|||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="?attr/actionBarSize"
|
||||||
app:liftOnScroll="true">
|
app:liftOnScroll="true">
|
||||||
|
|
||||||
<com.google.android.material.appbar.MaterialToolbar
|
<org.koitharu.kotatsu.base.ui.widgets.AnimatedToolbar
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
style="@style/Widget.Kotatsu.Toolbar"
|
style="@style/Widget.Kotatsu.Toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
app:navigationIcon="@drawable/ic_cross" />
|
app:navigationIcon="@drawable/ic_cross" />
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
android:id="@+id/recyclerView"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="?actionBarSize"
|
||||||
android:clipToPadding="false"
|
android:clipToPadding="false"
|
||||||
android:padding="@dimen/grid_spacing"
|
android:padding="@dimen/grid_spacing"
|
||||||
android:scrollbars="vertical"
|
android:scrollbars="vertical"
|
||||||
@@ -34,4 +36,4 @@
|
|||||||
app:spanCount="3"
|
app:spanCount="3"
|
||||||
tools:listitem="@layout/item_page_thumb" />
|
tools:listitem="@layout/item_page_thumb" />
|
||||||
|
|
||||||
</LinearLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
Reference in New Issue
Block a user