最佳答案
您可能需要使用底页
:
I - 制作一个bottomsheet.XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
android:padding="16dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<!-- add your content here -->
</LinearLayout>
II-现在在您的主要 Activity 中以 CoordinatorLayout 的直接子级的方式实现它
<include layout="@layout/bottomsheet" />
III- 对于 JAVA 代码,请使用以下内容:
inearLayout bottomSheetViewgroup = (LinearLayout) findViewById(R.id.bottom_sheet);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetViewgroup);
控制底部工作表(隐藏、展开、拖动、折叠):
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
PS-您可以通过以下方式处理:
STATE_EXPANDED: To completely expand the bottom sheet.
STATE_HIDE: To completely hide the bottom sheet.
STATE_COLLAPSED: To set the bottom sheet height with the value set on the peekHeight attribute.
关于java - 创建类似 Facebook 的菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42116586/