我正在尝试显示一个快餐栏(通过appcompat)向用户显示一条消息.它在手机上运行得非常好,但是在我得到的平板电脑上
和
我用来生成小吃店的代码是
Snackbar.make(mHomeContainer,R.string.rate_snackbar,Snackbar.LENGTH_LONG) .setAction("Rate",...) .show();
任何有关如何使这个小吃店居中的指导将非常感激
<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>
解决方法
您需要使用CoordinatorLayout才能实现此目的.这是一个描述如何做到这一点的
article.此外,您现在可能需要提供要用于非平板电脑和平板电脑的布局文件,以便您可以保留手机的全宽.如果您使用FAB,app bar和Snackbar的组合,这也是您需要使用的布局组件.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。