https://github.com/cpiz/BubbleView
A control/container with an arrow for Android, which can be fully customized by code or XML layout file.
https://github.com/cpiz/BubbleView
Last synced: 7 months ago
JSON representation
A control/container with an arrow for Android, which can be fully customized by code or XML layout file.
- Host: GitHub
- URL: https://github.com/cpiz/BubbleView
- Owner: cpiz
- Created: 2016-05-27T15:58:13.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-03-09T18:15:33.000Z (over 2 years ago)
- Last Synced: 2024-08-02T01:24:21.920Z (over 1 year ago)
- Language: Java
- Homepage:
- Size: 2.49 MB
- Stars: 985
- Watchers: 25
- Forks: 120
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-android-ui - BubbleView - 带箭头的Android气泡控件/容器类 (Popup)
README
# BubbleView for Android
[](https://travis-ci.org/cpiz/BubbleView) [ ](https://bintray.com/cpiz/maven/bubbleview/_latestVersion) [](https://jitpack.io/#cpiz/BubbleView)
[中文版README](README_CN.md)
BubbleView is a control/container with an arrow for Android, which can be fully customized by code or XML layout file.
* Arrow direction: up, down, left, right or none
* Should arrow auto point to its target
* Customizable arrow properties: size and location
* Customizable bubble properties: color, padding, borders and corner radius
* Bubble can be plain text view(BubbleTextView) or layout container(BubbleXxxLayout)
Download
--------
Add `jcenter()` to your project-level `build.gradle`
```
allprojects {
repositories {
jcenter()
}
}
```
Add `compile 'com.cpiz.bubbleview:bubbleview:{X.Y.Z}'` to your module-level `build.gradle`(see X.Y.Z in [Releases](https://github.com/cpiz/BubbleView/releases))
```
dependencies {
...
compile 'com.cpiz.bubbleview:bubbleview:{X.Y.Z}'
}
```
Specify the direction of arrow
-------
You can use app:bb_arrowDirection attribute to specify the direction of arrow. Its value can be: Left, Up, Right, Down or None. Arrow will be placed in the middle of the corresponding edge of bubble.

```XML
```
Point arrow to a specific target
-------
You can use app:bb_arrowTo attribute to specify the id of target view. The direction of arrow will be calculated automatically and it will point to the center of target.

```XML
```
Customize style
-------

```XML
```
### Use it as layout container
--------
Beside using BubbleTextView to display text, you can also use
* BubbleRelativeLayout
* BubbleLinearLayout
* BubbleFrameLayout
as bubble layout container and put customized content into it.

### Popup
--------
Can use BubblePopupWindow to wrap bubble, and show as popup.

* Support touch outside to close
* Support touch inside to close
* Support close in time
```
View rootView = LayoutInflater.from(this).inflate(R.layout.simple_text_bubble, null);
BubbleTextView bubbleView = (BubbleTextView) rootView.findViewById(R.id.popup_bubble);
window = new BubblePopupWindow(rootView, bubbleView);
window.setCancelOnTouch(true);
window.setCancelOnTouchOutside(true);
window.setCancelOnLater(3000);
window.showArrowTo(v, BubbleStyle.ArrowDirection.Left);
```
### Misc.
* Invoke methods like setBackground/setBackgroundColor of BubbleView will make the style settings invalid.
License
-------
Copyright 2017 Cpiz
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.