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

View file

@ -4,15 +4,6 @@ import android.content.Context
import android.content.res.Resources
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 {
val id = getResourceId(resName, "bool")
@ -22,4 +13,14 @@ object InternalResourceHelper {
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:background="?attr/colorPrimary"
android:theme="?attr/actionBarTheme"
app:layout_scrollFlags="scroll|enterAlways|snap" />
app:layout_scrollFlags="scroll|enterAlways" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabs"