Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B BoomMenu
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 114
    • Issues 114
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 5
    • Merge requests 5
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • 黄伟平
  • BoomMenu
  • Wiki
  • Ham Button

Ham Button · Changes

Page history
Updated Ham Button (markdown) authored Apr 07, 2017 by Weiping Huang's avatar Weiping Huang
Hide whitespace changes
Inline Side-by-side
Ham-Button.md
View page @ f92e3d70
...@@ -40,202 +40,286 @@ for (int i = 0; i < bmb.getPiecePlaceEnum().pieceNumber(); i++) { ...@@ -40,202 +40,286 @@ for (int i = 0; i < bmb.getPiecePlaceEnum().pieceNumber(); i++) {
Toast.makeText(HamButtonActivity.this, "Clicked " + index, Toast.LENGTH_SHORT).show(); Toast.makeText(HamButtonActivity.this, "Clicked " + index, Toast.LENGTH_SHORT).show();
} }
}) })
```
```
// Whether the image-view should rotate. // Whether the image-view should rotate.
.rotateImage(false) .rotateImage(false)
```
```
// Whether the ham-button contains a sub text-view. // Whether the ham-button contains a sub text-view.
.containsSubText(true) .containsSubText(true)
```
```
// Whether the boom-button should have a shadow effect. // Whether the boom-button should have a shadow effect.
.shadowEffect(true) .shadowEffect(true)
```
```
// Set the horizontal shadow-offset of the boom-button. // Set the horizontal shadow-offset of the boom-button.
.shadowOffsetX(20) .shadowOffsetX(20)
```
```
// Set the vertical shadow-offset of the boom-button. // Set the vertical shadow-offset of the boom-button.
.shadowOffsetY(0) .shadowOffsetY(0)
```
```
// Set the radius of shadow of the boom-button. // Set the radius of shadow of the boom-button.
.shadowRadius(Util.dp2px(20)) .shadowRadius(Util.dp2px(20))
```
```
// Set the corner-radius of the shadow. // Set the corner-radius of the shadow.
.shadowCornerRadius(Util.dp2px(5)) .shadowCornerRadius(Util.dp2px(5))
```
```
// Set the color of the shadow of boom-button. // Set the color of the shadow of boom-button.
.shadowColor(Color.parseColor("#ee000000")) .shadowColor(Color.parseColor("#ee000000"))
```
```
// Set the image resource when boom-button is at normal-state. // Set the image resource when boom-button is at normal-state.
.normalImageRes(R.drawable.jellyfish) .normalImageRes(R.drawable.jellyfish)
```
```
// Set the image drawable when boom-button is at normal-state. // Set the image drawable when boom-button is at normal-state.
.normalImageDrawable(getResources().getDrawable(R.drawable.jellyfish, null)) .normalImageDrawable(getResources().getDrawable(R.drawable.jellyfish, null))
```
```
// Set the image resource when boom-button is at highlighted-state. // Set the image resource when boom-button is at highlighted-state.
.highlightedImageRes(R.drawable.bat) .highlightedImageRes(R.drawable.bat)
```
```
// Set the image drawable when boom-button is at highlighted-state. // Set the image drawable when boom-button is at highlighted-state.
.highlightedImageDrawable(getResources().getDrawable(R.drawable.bat, null)) .highlightedImageDrawable(getResources().getDrawable(R.drawable.bat, null))
```
```
// Set the image resource when boom-button is at unable-state. // Set the image resource when boom-button is at unable-state.
.unableImageRes(R.drawable.butterfly) .unableImageRes(R.drawable.butterfly)
```
```
// Set the image drawable when boom-button is at unable-state. // Set the image drawable when boom-button is at unable-state.
.unableImageDrawable(getResources().getDrawable(R.drawable.butterfly, null)) .unableImageDrawable(getResources().getDrawable(R.drawable.butterfly, null))
```
```
// Set the rect of image. // Set the rect of image.
// By this method, you can set the position and size of the image-view in boom-button. // By this method, you can set the position and size of the image-view in boom-button.
// For example, builder.imageRect(new Rect(0, 50, 100, 100)) will make the // For example, builder.imageRect(new Rect(0, 50, 100, 100)) will make the
// image-view's size to be 100 * 50 and margin-top to be 50 pixel. // image-view's size to be 100 * 50 and margin-top to be 50 pixel.
.imageRect(new Rect(0, 0, Util.dp2px(60), Util.dp2px(60))) .imageRect(new Rect(0, 0, Util.dp2px(60), Util.dp2px(60)))
```
```
// Set the padding of image. // Set the padding of image.
// By this method, you can control the padding in the image-view. // By this method, you can control the padding in the image-view.
// For instance, builder.imagePadding(new Rect(10, 10, 10, 10)) will make the // For instance, builder.imagePadding(new Rect(10, 10, 10, 10)) will make the
// image-view content 10-pixel padding to itself. // image-view content 10-pixel padding to itself.
.imagePadding(new Rect(0, 0, 0, 0)) .imagePadding(new Rect(0, 0, 0, 0))
```
```
// Set the text resource when boom-button is at normal-state. // Set the text resource when boom-button is at normal-state.
.normalTextRes(R.string.text_ham_button_text_normal) .normalTextRes(R.string.text_ham_button_text_normal)
```
```
// Set the text resource when boom-button is at highlighted-state. // Set the text resource when boom-button is at highlighted-state.
.highlightedTextRes(R.string.text_ham_button_text_highlighted) .highlightedTextRes(R.string.text_ham_button_text_highlighted)
```
```
// Set the text resource when boom-button is at unable-state. // Set the text resource when boom-button is at unable-state.
.unableTextRes(R.string.text_ham_button_text_unable) .unableTextRes(R.string.text_ham_button_text_unable)
```
```
// Set the text when boom-button is at normal-state. // Set the text when boom-button is at normal-state.
.normalText("Put your normal text here") .normalText("Put your normal text here")
```
```
// Set the text when boom-button is at highlighted-state. // Set the text when boom-button is at highlighted-state.
.highlightedText("Put your highlighted text here") .highlightedText("Put your highlighted text here")
```
```
// Set the text when boom-button is at unable-state. // Set the text when boom-button is at unable-state.
.unableText("Unable!") .unableText("Unable!")
```
```
// Set the color of text when boom-button is at normal-state. // Set the color of text when boom-button is at normal-state.
.normalTextColor(Color.BLACK) .normalTextColor(Color.BLACK)
```
```
// Set the resource of color of text when boom-button is at normal-state.
.normalTextColorRes(R.color.black)
```
```
// Set the color of text when boom-button is at highlighted-state. // Set the color of text when boom-button is at highlighted-state.
.highlightedTextColor(Color.BLUE) .highlightedTextColor(Color.BLUE)
```
```
// Set the resource of color of text when boom-button is at highlighted-state.
.highlightedTextColorRes(R.color.blue)
```
```
// Set the color of text when boom-button is at unable-state. // Set the color of text when boom-button is at unable-state.
.unableTextColor(Color.RED) .unableTextColor(Color.RED)
```
```
// Set the resource of color of text when boom-button is at unable-state.
.unableTextColorRes(R.color.red)
```
```
// Set the rect of text. // Set the rect of text.
// By this method, you can set the position and size of the text-view in boom-button. // By this method, you can set the position and size of the text-view in boom-button.
// For example, builder.textRect(new Rect(0, 50, 100, 100)) will make the // For example, builder.textRect(new Rect(0, 50, 100, 100)) will make the
// text-view's size to be 100 * 50 and margin-top to be 50 pixel. // text-view's size to be 100 * 50 and margin-top to be 50 pixel.
.textRect(new Rect(Util.dp2px(70), Util.dp2px(10), Util.dp2px(280), Util.dp2px(40))) .textRect(new Rect(Util.dp2px(70), Util.dp2px(10), Util.dp2px(280), Util.dp2px(40)))
```
```
// Set the padding of text. // Set the padding of text.
// By this method, you can control the padding in the text-view. // By this method, you can control the padding in the text-view.
// For instance, builder.textPadding(new Rect(10, 10, 10, 10)) will make the // For instance, builder.textPadding(new Rect(10, 10, 10, 10)) will make the
// text-view content 10-pixel padding to itself. // text-view content 10-pixel padding to itself.
.textPadding(new Rect(0, 0, 0, 0)) .textPadding(new Rect(0, 0, 0, 0))
```
```
// Set the typeface of the text. // Set the typeface of the text.
.typeface(Typeface.DEFAULT_BOLD) .typeface(Typeface.DEFAULT_BOLD)
```
```
// Set the maximum of the lines of text-view. // Set the maximum of the lines of text-view.
.maxLines(2) .maxLines(2)
```
```
// Set the gravity of text-view. // Set the gravity of text-view.
.textGravity(Gravity.CENTER) .textGravity(Gravity.CENTER)
```
```
// Set the ellipsize of the text-view. // Set the ellipsize of the text-view.
.ellipsize(TextUtils.TruncateAt.MIDDLE) .ellipsize(TextUtils.TruncateAt.MIDDLE)
```
```
// Set the text size of the text-view. // Set the text size of the text-view.
.textSize(10) .textSize(10)
```
```
// Set the sub-text resource when boom-button is at normal-state. // Set the sub-text resource when boom-button is at normal-state.
.subNormalTextRes(R.string.text_ham_button_sub_text_normal) .subNormalTextRes(R.string.text_ham_button_sub_text_normal)
```
```
// Set the sub-text resource when boom-button is at highlighted-state. // Set the sub-text resource when boom-button is at highlighted-state.
.subHighlightedTextRes(R.string.text_ham_button_sub_text_highlighted) .subHighlightedTextRes(R.string.text_ham_button_sub_text_highlighted)
```
```
// Set the sub-text resource when boom-button is at unable-state. // Set the sub-text resource when boom-button is at unable-state.
.subUnableTextRes(R.string.text_ham_button_sub_text_unable) .subUnableTextRes(R.string.text_ham_button_sub_text_unable)
```
```
// Set the sub-text when boom-button is at normal-state. // Set the sub-text when boom-button is at normal-state.
.subNormalText("Put your normal sub-text here") .subNormalText("Put your normal sub-text here")
```
```
// Set the sub-text when boom-button is at highlighted-state. // Set the sub-text when boom-button is at highlighted-state.
.subHighlightedText("Put your highlighted sub-text here") .subHighlightedText("Put your highlighted sub-text here")
```
```
// Set the sub-text when boom-button is at unable-state. // Set the sub-text when boom-button is at unable-state.
.subUnableText("Sub unable!") .subUnableText("Sub unable!")
```
```
// Set the color of sub-text when boom-button is at normal-state. // Set the color of sub-text when boom-button is at normal-state.
.subNormalTextColor(Color.BLACK) .subNormalTextColor(Color.BLACK)
```
```
// Set the resource of color of sub-text when boom-button is at normal-state.
.subNormalTextColorRes(R.color.black)
```
```
// Set the color of sub-text when boom-button is at highlighted-state. // Set the color of sub-text when boom-button is at highlighted-state.
.subHighlightedTextColor(Color.WHITE) .subHighlightedTextColor(Color.BLUE)
```
```
// Set the resource of color of sub-text when boom-button is at highlighted-state.
.subHighlightedTextColorRes(R.color.blue)
```
```
// Set the color of sub-text when boom-button is at unable-state. // Set the color of sub-text when boom-button is at unable-state.
.subUnableTextColor(Color.YELLOW) .subUnableTextColor(Color.RED)
```
```
// Set the resource of color of sub-text when boom-button is at unable-state.
.subUnableTextColorRes(R.color.red)
```
```
// Set the rect of sub-text. // Set the rect of sub-text.
// By this method, you can set the position and size of the sub-text-view in boom-button. // By this method, you can set the position and size of the sub-text-view in boom-button.
// For example, builder.textRect(new Rect(0, 50, 100, 100)) will make the // For example, builder.textRect(new Rect(0, 50, 100, 100)) will make the
// sub-text-view's size to be 100 * 50 and margin-top to be 50 pixel. // sub-text-view's size to be 100 * 50 and margin-top to be 50 pixel.
.subTextRect(new Rect(Util.dp2px(70), Util.dp2px(35), Util.dp2px(280), Util.dp2px(55))) .subTextRect(new Rect(Util.dp2px(70), Util.dp2px(35), Util.dp2px(280), Util.dp2px(55)))
```
```
// Set the padding of sub-text. // Set the padding of sub-text.
// By this method, you can control the padding in the sub-text-view. // By this method, you can control the padding in the sub-text-view.
// For instance, builder.textPadding(new Rect(10, 10, 10, 10)) will make the // For instance, builder.textPadding(new Rect(10, 10, 10, 10)) will make the
// sub-text-view content 10-pixel padding to itself. // sub-text-view content 10-pixel padding to itself.
.subTextPadding(new Rect(0, 0, 0, 0)) .subTextPadding(new Rect(0, 0, 0, 0))
```
```
// Set the typeface of the sub-text. // Set the typeface of the sub-text.
.subTypeface(Typeface.SERIF) .subTypeface(Typeface.SERIF)
```
```
// Set the maximum of the lines of sub-text-view. // Set the maximum of the lines of sub-text-view.
.subMaxLines(1) .subMaxLines(1)
```
```
// Set the gravity of sub-text-view. // Set the gravity of sub-text-view.
.subTextGravity(Gravity.RIGHT) .subTextGravity(Gravity.RIGHT)
```
```
// Set the ellipsize of the sub-text-view. // Set the ellipsize of the sub-text-view.
.subEllipsize(TextUtils.TruncateAt.END) .subEllipsize(TextUtils.TruncateAt.END)
```
```
// Set the text size of the sub-text-view. // Set the text size of the sub-text-view.
.subTextSize(10) .subTextSize(10)
```
```
// Whether the boom-button should have a ripple effect. // Whether the boom-button should have a ripple effect.
.rippleEffect(true) .rippleEffect(true)
```
```
// The color of boom-button when it is at normal-state. // The color of boom-button when it is at normal-state.
.normalColor(Color.RED) .normalColor(Color.RED)
```
```
// The resource of color of boom-button when it is at normal-state. // The resource of color of boom-button when it is at normal-state.
.normalColorRes(R.color.red) .normalColorRes(R.color.red)
```
```
// The color of boom-button when it is at highlighted-state. // The color of boom-button when it is at highlighted-state.
.highlightedColor(Color.BLUE) .highlightedColor(Color.BLUE)
```
```
// The resource of color of boom-button when it is at highlighted-state. // The resource of color of boom-button when it is at highlighted-state.
.highlightedColorRes(R.color.blue) .highlightedColorRes(R.color.blue)
```
```
// The color of boom-button when it is at unable-state. // The color of boom-button when it is at unable-state.
.unableColor(Color.BLACK) .unableColor(Color.BLACK)
```
```
// The resource of color of boom-button when it is at unable-state. // The resource of color of boom-button when it is at unable-state.
.unableColorRes(R.color.black) .unableColorRes(R.color.black)
```
```
// The color of boom-button when it is just a piece. // The color of boom-button when it is just a piece.
.pieceColor(Color.WHITE) .pieceColor(Color.WHITE)
```
```
// The resource of color of boom-button when it is just a piece. // The resource of color of boom-button when it is just a piece.
.pieceColorRes(R.color.white) .pieceColorRes(R.color.white)
```
```
// Whether the boom-button is unable, default value is false. // Whether the boom-button is unable, default value is false.
.unable(false) .unable(false)
```
```
// Set the width of boom-button, in pixel. // Set the width of boom-button, in pixel.
.buttonWidth(Util.dp2px(300)) .buttonWidth(Util.dp2px(300))
```
```
// Set the height of boom-button, in pixel. // Set the height of boom-button, in pixel.
.buttonHeight(Util.dp2px(60)); .buttonHeight(Util.dp2px(60));
bmb.addBuilder(builder); bmb.addBuilder(builder);
......
Clone repository
Chapters
  1. Basic Usage
  2. Simple Circle Button
  3. Text Inside Circle Button
  4. Text Outside Circle Button
  5. Ham Button
  6. Share Style
  7. Button Place Alignments
  8. Different Ways to Boom
  9. Ease Animations for Buttons
  10. Different Order for Buttons
  11. Other Animations Attributes for Buttons
  12. Click Event and Listener
  13. Control BMB
  14. Use BMB in Action Bar
  15. Use BMB in Tool Bar
  16. Use BMB in List
  17. Use BMB in Fragment
  18. Attributes for BMB or Pieces on BMB
  19. Cache Optimization & Boom Area
  20. Version History
  21. Structure for BMB
  22. Change Boom Buttons Dynamically