Added CollapsingToolbarLayout in settings

This commit is contained in:
Prathamesh More 2021-09-23 18:35:30 +05:30
parent 42b9ea4107
commit c80293f33a
2 changed files with 17 additions and 9 deletions

View file

@ -45,11 +45,10 @@ class SettingsActivity : AbsBaseActivity(), ColorCallback, OnThemeChangedListene
} }
private fun setupToolbar() { private fun setupToolbar() {
setTitle(R.string.action_settings)
applyToolbar(binding.toolbar) applyToolbar(binding.toolbar)
val navController: NavController = findNavController(R.id.contentFrame) val navController: NavController = findNavController(R.id.contentFrame)
navController.addOnDestinationChangedListener { _, _, _ -> navController.addOnDestinationChangedListener { _, _, _ ->
binding.toolbar.title = binding.collapsingToolbarLayout.title =
navController.currentDestination?.let { getStringFromDestination(it) } navController.currentDestination?.let { getStringFromDestination(it) }
} }
} }

View file

@ -14,13 +14,22 @@
android:fitsSystemWindows="true" android:fitsSystemWindows="true"
app:liftOnScroll="true"> app:liftOnScroll="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="@+id/collapsingToolbarLayout"
style="?attr/collapsingToolbarLayoutLargeStyle"
android:layout_width="match_parent"
android:layout_height="?attr/collapsingToolbarLayoutLargeSize"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
<com.google.android.material.appbar.MaterialToolbar <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/toolbar" android:id="@+id/toolbar"
style="@style/Toolbar" style="@style/Toolbar"
android:layout_height="?actionBarSize"
app:layout_collapseMode="pin" app:layout_collapseMode="pin"
app:navigationIcon="@drawable/ic_keyboard_backspace_black" app:navigationIcon="@drawable/ic_keyboard_backspace_black"
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal" app:titleTextAppearance="@style/ToolbarTextAppearanceNormal"
tools:title="@string/action_settings" /> tools:title="@string/action_settings" />
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>