Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AlexLiuSheng/FloatView
floatview on windowmanager,and you can be easy to add call show by using it
https://github.com/AlexLiuSheng/FloatView
Last synced: about 1 month ago
JSON representation
floatview on windowmanager,and you can be easy to add call show by using it
- Host: GitHub
- URL: https://github.com/AlexLiuSheng/FloatView
- Owner: AlexLiuSheng
- Created: 2016-05-25T07:03:22.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-07T08:06:09.000Z (over 7 years ago)
- Last Synced: 2024-08-02T01:25:32.552Z (4 months ago)
- Language: Java
- Homepage:
- Size: 4.47 MB
- Stars: 242
- Watchers: 8
- Forks: 49
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-github-android-ui - FloatView - 类似来电秀的效果 (其他)
README
# FloatView
floatview on windowmanager,and you can be easy to add call show by using it自定义floatview,无需申明悬浮框权限,利用WindowManager TYPE_TOAST实现全站浮动式按钮,重写touch事件实现任意拖动,将view加入windowmanager层,可以使用控件实现类似来电秀的效果。
## MIUI使用TYPE_TOAST也会无效,所以MIUI系统中需要在manifest里面注册SYSTEM_ALERT_Winow权限,其他系统可以不用.
### 导入:
`compile 'com.allenliu:floatview:1.0.1'`
### 初始化Floatview:
FloatView(Context context, int x, int y, View childView)
or
FloatView(Context context, int x, int y, int layoutres)
### 其他方法:
```
updateFloatViewPosition(int x, int y)//更新位置setFloatViewClickListener(IFloatViewClick listener)`
addToWindow()//加入窗口
setIsAllowTouch(boolean flag)//是否允许拖动
removeFromWindow()//移除窗口
```由于控件显示在windowmanager上,所以控件显示的生命周期需要自己手动管理,可以在Application或者基层Activity里控制显示和隐藏。
### 来电秀
利用控件也可以显示在来电秀上。
由于继承自linearlayout所以可以添加子view,可以初始化时将View或layout传入,也可以手动addview,在监听来电时加入view即可,有兴趣的朋友可以
参考下源码
case TelephonyManager.CALL_STATE_RINGING:
if (!viewIsShow) {
viewIsShow = true;
if (floatView == null)
floatView = new FloatView(context, 0, 0, R.layout.callshow_layout);
floatView.addToWindow();
}