AppCompat app is not tablet oriented

I am trying to show a snackbar (via appcompat) to display a message to the user. It works great on phones, however on tablets I get

portrait

and

landscape

The code I use to create a snack is

Snackbar.make(mHomeContainer, R.string.rate_snackbar, Snackbar.LENGTH_LONG) .setAction("Rate", ...) .show(); 

Any recommendations on how to make this centering with appetizers would be greatly appreciated.

 <android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <View android:id="@+id/status_bar" android:layout_width="match_parent" android:layout_height="0dp" android:background="@color/main" android:elevation="8dp"/> <include layout="@layout/toolbar" /> <RelativeLayout android:id="@+id/home_container" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/main_content" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentBottom="true" /> <ListView android:id="@+id/home_search_list" android:visibility="gone" android:layout_width="match_parent" android:layout_height="match_parent" android:background="#88000000"/> </RelativeLayout> </LinearLayout> <include layout="@layout/navigation_list" /> </android.support.v4.widget.DrawerLayout> 
+7
android material-design appcompat
source share
2 answers

You need to use CoordinatorLayout for this to happen. Here is an article that describes how to do this. In addition, you will most likely have to provide the layout files that you want to use for non-tablets or tablets so that you can keep the full width for your phones. It is also a layout component that you need to use if you use a combination of FAB, application bar and Snackbar.

+6
source share

In the design support library v22.2.0, the default gravity value for Snackbar was just Gravity.BOTTOM.

In version 22.2.1, this problem was fixed: https://code.google.com/p/android/issues/detail?id=176383

+4
source share

All Articles