I'm trying to show a custom Snackbar as in this example:
how to customize snackBar's layout?
This is my custom code to create a Snackbar:
protected void showSnackBar(View view) {
Snackbar snackbar = Snackbar.make(view, "", Snackbar.LENGTH_INDEFINITE);
Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout) snackbar.getView();
TextView textView = (TextView) layout.findViewById(android.support.design.R.id.snackbar_text);
textView.setVisibility(View.INVISIBLE);
LayoutInflater inflater = LayoutInflater.from(this);
View snackView = inflater.inflate(R.layout.custom_snackbar, null);
layout.addView(snackView, 0);
ViewGroup group = (ViewGroup) snackbar.getView();
group.setBackgroundColor(ContextCompat.getColor(this, R.color.green_wasabi));
snackbar.show();
}
My goal is to have a method in my base activity to call from any other activity.
But my problem is when I show the Snackbar, that it is shown under the keyboard:
In addition it does not show all views of layout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/relativelayout_sync_schedule_runs"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:padding="10dp"
android:background="@color/green_wasabi"
android:layout_alignParentBottom="true"
android:layout_gravity="center_horizontal|bottom">
<ProgressBar
android:id="@+id/progressbar_infinite"
android:layout_width="30dp"
android:layout_height="30dp"
style="@android:style/Widget.Material.ProgressBar.Small"
android:layout_centerVertical="true"
android:layout_marginRight="15dp"
android:layout_toLeftOf="@+id/textview_sync_runs"
android:layout_toStartOf="@+id/textview_sync_runs" />
<com.runator.ui.widget.text.CustomTextView
android:id="@+id/textview_sync_runs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/import_runs"
android:textColor="@color/black_midnight"
style="@style/texts.medium_medium_big"
app:font_type="bold"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"/>
If anyone has any suggestions I will be happy to hear it.
Thanks in advance.