# HappyBubble [![GitHub release](https://img.shields.io/badge/Download-DemoApk&AAR-green.svg)](https://github.com/xujiaji/HappyBubble/releases/tag/v1.2.6) [![maven](https://img.shields.io/badge/bintray-1.2.6-brightgreen.svg)](https://bintray.com/xujiaji/maven/happy-bubble/1.2.6) ![bubble](https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/github/HappyBubble/en/img5.png) Bubble layout change at will; Dialog according to click View position display; [中文文档](https://blog.xujiaji.com/post/happy-bubble) [Old README(旧文档)](README-old.md) ## update |version| update description |screenshot| |:-:|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-:| |1.2.6| fix position in list view [#43](https://github.com/xujiaji/HappyBubble/issues/43) || |1.2.5| fix position vertical offset [#36](https://github.com/xujiaji/HappyBubble/issues/36) || |1.2.4| fix status bar height fetch[#31](https://github.com/xujiaji/HappyBubble/issues/31) || |1.2.3| fix bubbles within the margin problem || |1.2.2| New Features "Set Bubble Border and Border Color"[#23](https://github.com/xujiaji/HappyBubble/issues/23) |![1.2.2特性](readme/1_2_2.gif)| |1.2.1| New Features "Set Bubble Background" |![1.2.1特性](readme/1_2_1.jpeg)| |1.2.0| feat: arrow radius custom || |1.1.9| fix init position offset; feat: show dialog by clicked position || |1.1.8| fix status light mode when call 'setTransParentBackground' || |1.1.7| fix position error, fix `autoPosition` invalid ... [#13](https://github.com/xujiaji/HappyBubble/issues/13) [#11](https://github.com/xujiaji/HappyBubble/issues/11) [#10](https://github.com/xujiaji/HappyBubble/issues/10) || |1.1.6| [feat position priority: #9](https://github.com/xujiaji/HappyBubble/issues/9) || |1.1.5| [fix: #8](https://github.com/xujiaji/HappyBubble/issues/8) || |1.1.4| ①New method `setLayout(int width, int height, int margin)`,width(set the width of the bubble)、height(set the height of the bubble)、margin(set the distance from the screen edge, only valid if you set width or height to MATCH_PARENT).
②`autoPosition(true)`method is ready to be deprecated (and can be used now), using the new method `autoPosition(Auto)`.If both are used, `autoPosition(Auto)` is used directly. Please refer to the "Method Reference Table" below. || |1.1.3| ①By calling setClickedView can be directly updated the current location of the dialog.
②Add a new setRelativeOffset (int) method that sets the offset of the dialog relative to the view being clicked (Negative value: Offset to the center of the view being clicked; Positive value: Offset to the outside of the view being clicked).
③[Test page:SetClickedViewTestActivity.java](app/src/main/java/com/xujiaji/happybubbletest/SetClickedViewTestActivity.java) |![1.1.3.gif](https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/github/HappyBubble/en/1.1.3.gif)| |1.1.2| Fix default values does not adaptation screen. || |1.1.1| Repair the size of the change, there is no response to change the location; repair contact offset the top of the problem; || |1.1.0| ① Dialog interactive events passed to the Activity to achieve not without closing the dialog box,can opreate Activity.
② Add automatically according to click the distance from the edge of the screen to determine the location of the dialog box.
③Added "autoPosition" and "setThroughEvent" methods, please refer to "BubbleDialog method reference table" |![1.1.0.gif](https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/github/HappyBubble/en/1.1.0.gif)| |1.0.3| Continue to optimize the click outside the bubble will be dismiss; fix some Dialog around Dialog can not dismiss; || |1.0.2| Fix click on the dialog edge can not be canceled. || ## Which apps use it ? |Todo| |-| |[![Todo](https://raw.githubusercontent.com/xujiaji/Todo/master/app/src/main/res/mipmap-hdpi/ic_launcher.png)](https://www.coolapk.com/apk/211388)| ## How to get started? Add HappyBubble dependency into your build.gradle ``` groovy repositories { mavenCentral() } dependencies { implementation 'com.github.xujiaji:happy-bubble:1.2.6' } ``` ## How to use HappyBubble-BubbleDialog? > Method reference table > For details, please refer to the case code and [attrs.xml](https://github.com/xujiaji/HappyBubble/blob/master/happy-bubble/src/main/res/values/attrs.xml) |Method|Param|Description| |:-|:-:|:-| |addContentView|View|Fill content view| |setClickedView|View|Clicked view| |setPosition|enum ... BubbleDialog.Position:LEFT, TOP, RIGHT, BOTTOM|BubbleDialog relative to the location of the view being clicked. If you pass in multiple locations, the higher the priority of the front position| |setOffsetX|int|If you are not satisfied with the x position, you need to adjust.| |setOffsetY|int|If you are not satisfied with the y position, you need to adjust.| |setBubbleLayout|BubbleLayout|Custom BubbleLayout| |setTransParentBackground|-|Transparent background| |softShowUp|-|When EditText gets the focus, you want it to move up.| |show|-|display| |autoPosition| enum
`(Auto:AROUND,UP_AND_DOWN,LEFT_AND_RIGHT)`|The position function is automatically determined to show the maximum space at the edge of the screen when the View is clicked.When turned on, the “setPosition” function is disabled.
AROUND:Clicked around the View;
UP_AND_DOWN:Clicked View is displayed above and below;
LEFT_AND_RIGHT:Clicked around the View to display;| |setThroughEvent|boolean, boolean|The first parameter, "isThroughEvent", sets whether or not to penetrate the Dialog gesture interaction.
The second argument, "cancelable", clicks whether the blank can cancel Dialog, only valid if "isThroughEvent = false".| |setRelativeOffset|int|Set the dialog relative to the offset of the View being clicked (negative: Offset to the center of the view being clicked; Positive: Offset to the outside of the clicked view). This setting directly affects the setOffsetX and setOffsetY methods.| |setLayout|int,int,int|Set the width and height of the bubble and the distance from the edge of the screen.
The first parameter: width (set the width of the bubble);
The second parameter: height (set the height of the bubble);
he third parameter: margin (sets the distance from the edge of the screen, only if you set width or height to MATCH_PARENT).
Width Height is px or MATCH_PARENT| ### The easiest to achieve. ||| |-|-| |![exampel1](https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/github/HappyBubble/en/img_example1.png)|![exampel2](https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/github/HappyBubble/en/img_example2.png)| ``` java new BubbleDialog(this) .addContentView(LayoutInflater.from(this).inflate(R.layout.dialog_view3, null)) .setClickedView(mButton) .show(); ``` ### Off 8dp down. ![exampel3](https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/github/HappyBubble/en/img_example3.png) ``` java new BubbleDialog(this) .addContentView(LayoutInflater.from(this).inflate(R.layout.dialog_view3, null)) .setClickedView(mButton4) .setPosition(mPosition) .setOffsetY(8) .show(); ``` ### When the input box is covered by the keyboard. ![exampel4](https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/github/HappyBubble/en/gif_example4.gif) ``` java new BubbleDialog(this) .addContentView(LayoutInflater.from(this).inflate(R.layout.dialog_view, null)) .setClickedView(mButton12) .setPosition(mPosition) .softShowUp() .show(); ``` ### Custom BubbleLayout. ![exampel5](https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/github/HappyBubble/20190407164631.png) ``` java BubbleLayout bl = new BubbleLayout(this); bl.setBubbleColor(Color.YELLOW); bl.setShadowColor(Color.RED); bl.setLookLength(Util.dpToPx(this, 18)); bl.setLookWidth(Util.dpToPx(this, 24)); bl.setBubbleRadius(Util.dpToPx(this, 3)); new BubbleDialog(this) .addContentView(LayoutInflater.from(this).inflate(R.layout.dialog_view5, null)) .setClickedView(mButton8) .setPosition(mPosition) .setBubbleLayout(bl) .show(); ``` ### Custom BubbleDialog, actionable BubbleDialog. ![exampel6](https://raw.githubusercontent.com/xujiaji/xujiaji.github.io/pictures/github/HappyBubble/en/gif_example6.gif) > 1.layout ``` xml