Remove toolbar snapping

This commit is contained in:
arkon 2021-04-15 10:05:47 -04:00
parent 1f729f1cb3
commit d981245723
3 changed files with 18 additions and 20 deletions

View File

@ -98,15 +98,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
WindowCompat.setDecorFitsSystemWindows(window, false) WindowCompat.setDecorFitsSystemWindows(window, false)
binding.appbar.applyInsetter { binding.appbar.applyInsetter {
type(navigationBars = true, statusBars = true) { type(navigationBars = true, statusBars = true) {
padding(left = true, right = true) padding(left = true, top = true, right = true)
}
type(statusBars = true) {
margin(top = true)
}
}
binding.bottomNav.applyInsetter {
type(navigationBars = true) {
padding()
} }
} }
binding.rootFab.applyInsetter { binding.rootFab.applyInsetter {
@ -114,6 +106,11 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
margin() margin()
} }
} }
binding.bottomNav.applyInsetter {
type(navigationBars = true) {
padding()
}
}
// Make sure navigation bar is on bottom before we modify it // Make sure navigation bar is on bottom before we modify it
ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _, insets -> ViewCompat.setOnApplyWindowInsetsListener(binding.root) { _, insets ->
@ -124,7 +121,7 @@ class MainActivity : BaseViewBindingActivity<MainActivityBinding>() {
Color.TRANSPARENT Color.TRANSPARENT
} else { } else {
// Set navbar scrim 70% of navigationBarColor // Set navbar scrim 70% of navigationBarColor
getResourceColor(android.R.attr.navigationBarColor, .7F) getResourceColor(android.R.attr.navigationBarColor, 0.7F)
} }
} }
insets insets

View File

@ -4,15 +4,6 @@ import android.content.Context
import android.content.res.Resources import android.content.res.Resources
object InternalResourceHelper { object InternalResourceHelper {
/**
* Get resource id from system resources
* @param resName resource name to get
* @param type resource type of [resName] to get
* @return 0 if not available
*/
private fun getResourceId(resName: String, type: String): Int {
return Resources.getSystem().getIdentifier(resName, type, "android")
}
fun getBoolean(context: Context, resName: String, defaultValue: Boolean): Boolean { fun getBoolean(context: Context, resName: String, defaultValue: Boolean): Boolean {
val id = getResourceId(resName, "bool") val id = getResourceId(resName, "bool")
@ -22,4 +13,14 @@ object InternalResourceHelper {
defaultValue defaultValue
} }
} }
/**
* Get resource id from system resources
* @param resName resource name to get
* @param type resource type of [resName] to get
* @return 0 if not available
*/
private fun getResourceId(resName: String, type: String): Int {
return Resources.getSystem().getIdentifier(resName, type, "android")
}
} }

View File

@ -19,7 +19,7 @@
android:layout_height="?attr/actionBarSize" android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary" android:background="?attr/colorPrimary"
android:theme="?attr/actionBarTheme" android:theme="?attr/actionBarTheme"
app:layout_scrollFlags="scroll|enterAlways|snap" /> app:layout_scrollFlags="scroll|enterAlways" />
<com.google.android.material.tabs.TabLayout <com.google.android.material.tabs.TabLayout
android:id="@+id/tabs" android:id="@+id/tabs"