# BubbleView for Android [![build](https://travis-ci.org/cpiz/BubbleView.svg?branch=master)](https://travis-ci.org/cpiz/BubbleView) [ ![Download](https://api.bintray.com/packages/cpiz/maven/bubbleview/images/download.svg)](https://bintray.com/cpiz/maven/bubbleview/_latestVersion) [![build](https://jitpack.io/v/cpiz/BubbleView.svg)](https://jitpack.io/#cpiz/BubbleView) [README in English](README.md) BubbleView是带箭头的Android气泡控件/容器类,支持在布局中通过自定义属性或代码进行丰富的定制 * 自定义箭头朝向:上、下、左、右、无 * 箭头自动指向目标 * 箭头高度、宽度、位置 * 气泡填充颜色、填充Padding、边框、边框颜色、圆角 * BubbleTextView文字气泡/BubbleXxxLayout容器气泡 下载 -------- 在项目目录的 `build.gradle` 中增加 `jcenter()` ``` allprojects { repositories { jcenter() } } ``` 在模块目录的 `build.gradle` 中增加 `compile 'com.cpiz.bubbleview:bubbleview:{X.Y.Z}'`(X.Y.Z 见 [Releases](https://github.com/cpiz/BubbleView/releases)) ``` dependencies { ... compile 'com.cpiz.bubbleview:bubbleview:{X.Y.Z}' } ``` 箭头指定特定方向 -------- 指定属性app:bb_arrowDirection,可选值为Left|Up|Right|Down|None,默认箭头位置在气泡侧面居中。 ![指定箭头方向](./screenshots/1.png) ```XML ``` 箭头指向特定对象 ------- 指定属性app:bb_arrowTo为目标对象ViewId,将自动确定箭头方向,并将箭头位置指向目标中心。 ![箭头指向特定对象](./screenshots/2.png) ```XML ``` 自定义样式 ------- ![自定义样式](./screenshots/3.png) ```XML ``` ### 作为容器 -------- 除直接使用BubbleTextView显示文字外,还可以使用 * BubbleRelativeLayout * BubbleLinearLayout * BubbleFrameLayout 作为气泡容器,自定义包含内容 ![作为容器](./screenshots/4.png) ### 弹出显示 -------- 还可通过BubblePopupWindow来包装,弹出显示 ![弹出显示](./screenshots/5.gif) * 支持点击气泡之外关闭 * 支持点击气泡关闭 * 支持定时关闭 ``` 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); ``` ### 其它 * 如果自行指定BubbleView的setBackground/setBackgroundColor等,将导致气泡样式失效 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.