gpt4 book ai didi

java - 创建类似 Facebook 的菜单

转载 作者:行者123 更新时间:2023-12-01 08:54:43 32 4
gpt4 key购买 nike

我想打开一个类似于 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com