public class MaterialPopupMenuBuilder
Builder for creating a class MaterialPopupMenu.
The class MaterialPopupMenu must have at least one section.
All sections must also have at least one item and each item must have a non-null label set.
class MaterialPopupMenu,
class MaterialPopupMenu| Modifier and Type | Class and Description |
|---|---|
static class |
MaterialPopupMenuBuilder.AbstractItemHolder |
static class |
MaterialPopupMenuBuilder.CustomItemHolder
Holds section custom item info for the builder. This gets converted to MaterialPopupMenu.PopupMenuCustomItem.
|
static class |
MaterialPopupMenuBuilder.ItemHolder
Holds section item info for the builder. This gets converted to MaterialPopupMenu.PopupMenuItem.
|
static class |
MaterialPopupMenuBuilder.SectionHolder
Holds section info for the builder. This gets converted to MaterialPopupMenu.PopupMenuSection.
|
| Constructor and Description |
|---|
MaterialPopupMenuBuilder()
Builder for creating a
class MaterialPopupMenu. |
| Modifier and Type | Method and Description |
|---|---|
MaterialPopupMenu |
build()
Creates a
class MaterialPopupMenu with the already configured params. |
java.lang.Integer |
getDropDownHorizontalOffset()
Setting this to non-
null value will override android:dropDownHorizontalOffset set by the style applied in style. |
java.lang.Integer |
getDropDownVerticalOffset()
Setting this to non-
null value will override android:dropDownVerticalOffset set by the style applied in style. |
int |
getDropdownGravity()
Gravity of the dropdown list. This is commonly used to
set gravity to START or END for alignment with the anchor.
Setting Gravity.BOTTOM will anchor the dropdown list below the view.
|
int |
getFixedContentWidthInPx()
Setting this to a non-zero value will force the width of the popup menu to be exactly this value.
If set to 0, the default mechanism for measuring popup menu width will be applied.
|
int |
getStyle()
Style of the popup menu.
|
void |
section(kotlin.jvm.functions.Function1<? super com.github.zawadz88.materialpopupmenu.MaterialPopupMenuBuilder.SectionHolder,kotlin.Unit> init)
Adds a new section to the popup menu.
|
void |
setDropDownHorizontalOffset(java.lang.Integer p)
Setting this to non-
null value will override android:dropDownHorizontalOffset set by the style applied in style. |
void |
setDropDownVerticalOffset(java.lang.Integer p)
Setting this to non-
null value will override android:dropDownVerticalOffset set by the style applied in style. |
void |
setDropdownGravity(int p)
Gravity of the dropdown list. This is commonly used to
set gravity to START or END for alignment with the anchor.
Setting Gravity.BOTTOM will anchor the dropdown list below the view.
|
void |
setFixedContentWidthInPx(int p)
Setting this to a non-zero value will force the width of the popup menu to be exactly this value.
If set to 0, the default mechanism for measuring popup menu width will be applied.
|
void |
setStyle(int p)
Style of the popup menu.
|
public MaterialPopupMenuBuilder()
Builder for creating a class MaterialPopupMenu.
The class MaterialPopupMenu must have at least one section.
All sections must also have at least one item and each item must have a non-null label set.
class MaterialPopupMenu,
class MaterialPopupMenupublic int getStyle()
Style of the popup menu.
For dark themes you should use R.style.Widget_MPM_Menu_Dark.
Setting this to 0 will make the popup use the default style resolved based on context
passed to MaterialPopupMenu.show function. You can customize that default style by defining
R.attr.materialPopupMenuStyle in your theme style.
NOTE: make sure that all of the attributes that are declared in R.style.Widget_MPM_Menu are also declared in your style.
MaterialPopupMenu.showpublic void setStyle(int p)
Style of the popup menu.
For dark themes you should use R.style.Widget_MPM_Menu_Dark.
Setting this to 0 will make the popup use the default style resolved based on context
passed to MaterialPopupMenu.show function. You can customize that default style by defining
R.attr.materialPopupMenuStyle in your theme style.
NOTE: make sure that all of the attributes that are declared in R.style.Widget_MPM_Menu are also declared in your style.
MaterialPopupMenu.showpublic int getDropdownGravity()
Gravity of the dropdown list. This is commonly used to set gravity to START or END for alignment with the anchor. Setting Gravity.BOTTOM will anchor the dropdown list below the view.
public void setDropdownGravity(int p)
Gravity of the dropdown list. This is commonly used to set gravity to START or END for alignment with the anchor. Setting Gravity.BOTTOM will anchor the dropdown list below the view.
public int getFixedContentWidthInPx()
Setting this to a non-zero value will force the width of the popup menu to be exactly this value. If set to 0, the default mechanism for measuring popup menu width will be applied.
public void setFixedContentWidthInPx(int p)
Setting this to a non-zero value will force the width of the popup menu to be exactly this value. If set to 0, the default mechanism for measuring popup menu width will be applied.
@Nullable public java.lang.Integer getDropDownVerticalOffset()
Setting this to non-null value will override android:dropDownVerticalOffset set by the style applied in style.
stylepublic void setDropDownVerticalOffset(@Nullable
java.lang.Integer p)
Setting this to non-null value will override android:dropDownVerticalOffset set by the style applied in style.
style@Nullable public java.lang.Integer getDropDownHorizontalOffset()
Setting this to non-null value will override android:dropDownHorizontalOffset set by the style applied in style.
stylepublic void setDropDownHorizontalOffset(@Nullable
java.lang.Integer p)
Setting this to non-null value will override android:dropDownHorizontalOffset set by the style applied in style.
stylepublic void section(@NotNull
kotlin.jvm.functions.Function1<? super com.github.zawadz88.materialpopupmenu.MaterialPopupMenuBuilder.SectionHolder,kotlin.Unit> init)
Adds a new section to the popup menu.
Sections are separated with a divider from each other and must contain at least one item. Section titles are optional.
init - block containing section definition@NotNull public MaterialPopupMenu build()
Creates a class MaterialPopupMenu with the already configured params.
This might throw IllegalStateException if it wasn't configured properly
see class description for validation details.
class MaterialPopupMenu,
IllegalStateException