Reputation: 149
I want to open a menu of options similar to that of Facebook. I did a search but I did not find anything ...
Upvotes: 0
Views: 126
Reputation: 3563
You will probably be needing to use Bottom Sheets
for that :
I - Make a 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- now in your main activity implement it in a way it is a direct child of a CoordinatorLayout
<include layout="@layout/bottomsheet" />
III- For the JAVA code use the following:
inearLayout bottomSheetViewgroup = (LinearLayout) findViewById(R.id.bottom_sheet);
BottomSheetBehavior bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetViewgroup);
To control your bottom sheet (hiding, expanding, dragging, collapsing):
bottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
PS- you can handle this by :
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.
Upvotes: 1