Reputation: 1
I am working in a project with dynamic modules. Where we a navigation bar that is in the Dashboard module. But I working in another module, that the view is a fragment tied to the Dashboard Activity. And I want to show an snackbar, but my problem is that the snackbar instead of showing at the bottom of the fragment view is showing in the navigation bar (I attached photos). I have tried several things but i don't know how to solved.
This is how i creating the snackbar:
Snackbar.make(it, "test", Snackbar.LENGTH_INDEFINITE).show()
This is my layout of the fragment:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:textAlignment="center"
android:text="Welcome"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
The image of the app withour snackbar
Upvotes: 0
Views: 240
Reputation: 189
You can set margin to your Snackbar like this:
Snackbar snack = Snackbar.make(coordinatorLayout, "test", Snackbar.LENGTH_LONG);
CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams)
snack.getView().getLayoutParams();
params.setMargins(0, 0, 0, bottomBarHeight);
snack.getView().setLayoutParams(params);
snack.show();
Upvotes: 1