java - 创建类似 Facebook 的菜单

标签 java android

我想打开一个类似于 Facebook 的选项菜单。我进行了搜索,但没有找到任何东西... enter image description here

最佳答案

您可能需要使用底页:

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/

相关文章:

Java分割嵌套括号字符串

java - 当 JPanel 更改时,旧 JPanel 的元素将被留下

Java JOGL编译错误

Android 列表小部件问题

Android Firebase Facebook 身份验证注销功能

android - 从应用程序缓存加载时 ListView 滞后

android - Android 中的音频播放器

java - 在 Java 中将 vector 作为参数发送

使用 class.getSimpleName() 的 Java switch 语句给出 Constant express required 错误

android - 使用 App Engine 更新应用程序中的数据库