(this error is occuring in a big project, so i made a small one for easier demonstration)
I have been stuggling with this problem for a while now and i just cant find an answer anywhere
~Layout
I want to push up the fab when a Snackbar is being displayed. When the bottom navigation bar is removed and i show a snackbar, the fab is being pushed up. But when i insert the bottom navigation bar, the snackbar appears, but the fab is not being pushed up
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:layout_anchor="@id/bar"
app:layout_anchorGravity="bottom|end" />
<com.google.android.material.bottomnavigation.BottomNavigationView
android:background="@color/design_default_color_secondary"
android:id="@+id/bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_insetEdge="bottom"
android:layout_gravity="bottom"
app:menu="@menu/menu"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val button = findViewById<Button>(R.id.button)
button.setOnClickListener {
Snackbar
.make(it, "tttt", Snackbar.LENGTH_LONG)
.setAnchorView(findViewById(R.id.bar))
.show()
}
}
}
thanks in advance :)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…