Skip to content

Commit

Permalink
Fix flickering snackbar (#3619)
Browse files Browse the repository at this point in the history
The root view must not set `android:animateLayoutChanges="true"`.

material-components/material-components-android#648

Closes #3393

Signed-off-by: mueller-ma <mueller-ma@users.noreply.github.com>
  • Loading branch information
mueller-ma authored Mar 12, 2024
1 parent 77cdb1f commit 2bea156
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ abstract class AbstractBaseActivity : AppCompatActivity(), CoroutineScope {
protected open val forceNonFullscreen = false
private var authPrompt: AuthPrompt? = null
private lateinit var coordinator: CoordinatorLayout
protected lateinit var layoutForSnackbar: View
private lateinit var toolbar: MaterialToolbar
private lateinit var content: View
lateinit var appBarLayout: AppBarLayout
Expand Down Expand Up @@ -107,6 +108,7 @@ abstract class AbstractBaseActivity : AppCompatActivity(), CoroutineScope {
enableDrawingBehindStatusBar()

coordinator = findViewById(R.id.coordinator)
layoutForSnackbar = coordinator
content = findViewById(R.id.activity_content)
insetsController = WindowInsetsControllerCompat(window, coordinator)

Expand Down Expand Up @@ -235,7 +237,7 @@ abstract class AbstractBaseActivity : AppCompatActivity(), CoroutineScope {
throw IllegalArgumentException("Tag is empty")
}

val snackbar = Snackbar.make(coordinator, message, duration)
val snackbar = Snackbar.make(layoutForSnackbar, message, duration)
if (actionResId != 0 && onClickListener != null) {
snackbar.setAction(actionResId) { onClickListener() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,7 @@ class MainActivity : AbstractBaseActivity(), ConnectionFactory.UpdateListener {

private fun setupDrawer() {
drawerLayout = findViewById(R.id.drawer_container)
layoutForSnackbar = drawerLayout
drawerToggle = ActionBarDrawerToggle(this, drawerLayout,
R.string.drawer_open, R.string.drawer_close)
drawerLayout.addDrawerListener(drawerToggle)
Expand Down

0 comments on commit 2bea156

Please sign in to comment.