You can create awesome menus with bottom sheet experience in a few lines
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.mazenrashed:BottomSheetMenu:${LAST_VERSION}'
}
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/option1"
android:icon="@drawable/ic_baseline_alarm_off_24"
android:title="Turn alarm on" />
<item
android:id="@+id/option2"
android:icon="@drawable/ic_baseline_alarm_on_24"
android:title="Turn alarm off" />
</menu>
val bottomSheet = MenuBottomSheet.Builder()
.setMenuRes(R.menu.test_menu)
.closeAfterSelect(true)
.build()
- You can add the menu items programmatically without menu file
val menuItems = arrayListOf(
MenuBottomSheetItem("Turn alarm on", R.drawable.ic_baseline_alarm_on_24),
MenuBottomSheetItem("Turn alarm off", R.drawable.ic_baseline_alarm_off_24)
)
val bottomSheet = MenuBottomSheet.Builder()
.setMenuItems(menuItems)
.closeAfterSelect(true)
.build()
bottomSheet.show(this)
bottomSheet.onSelectMenuItemListener = { position: Int, id: Int? ->
when (id) {
R.id.option1 -> Toast.makeText(this, "On", Toast.LENGTH_SHORT).show()
R.id.option2 -> Toast.makeText(this, "Off", Toast.LENGTH_SHORT).show()
else -> Toast.makeText(this, "Nothing", Toast.LENGTH_SHORT).show()
}
} ```
We welcome contributions !
- ⇄ Pull requests and ★ Stars are always welcome.