Comments (5)
我今天闲来有空 研究了一下怎么按需求创建并显示悬浮窗
首先把库下载下来
修改FloatWindow类里的build方法 ,使其返回IFloatWindow类型, 再在build方法的后面 增加一行
return floatWindowImpl;
代码如下:
//这里本来是void类型 修改成IFloatWindow
public IFloatWindow build() {
if (mFloatWindowMap == null) {
mFloatWindowMap = new HashMap<>();
}
if (mFloatWindowMap.containsKey(mTag)) {
throw new IllegalArgumentException("FloatWindow of this tag has been added, Please set a new tag for the new FloatWindow");
}
if (mView == null && mLayoutId == 0) {
throw new IllegalArgumentException("View has not been set!");
}
if (mView == null) {
mView = Util.inflate(mApplicationContext, mLayoutId);
}
IFloatWindow floatWindowImpl = new IFloatWindowImpl(this);
mFloatWindowMap.put(mTag, floatWindowImpl);
return floatWindowImpl; //这里返回floatWindowImpl
}
调用的时候 在build后面调用一次 show()方法即可 ,如下:
FloatWindow.with(MyApplication.getContext())
.setView(view)
.setDesktopShow(true)
.build()
.show()
from floatwindow.
我也发现了这个问题
from floatwindow.
是这样的 如果在onCreate里初始化界面呢 悬浮窗就会显示 当在按钮的setOnClickListener 里初始化呢 就需要第二次进入才会显示悬浮窗
from floatwindow.
好神奇
from floatwindow.
悬浮窗的设计初衷用于多 Activity 显示,我当初的思路是在 Application 中创建这个“全局视图”,所以代码逻辑是在 Activity Resumed 时才会处理悬浮窗的显示与否,但是这一全局视图可能在某个Activity 中才会设置开启,针对这种情况可以在初始化后紧接着调用
FloatWindow.get().show();
即可。
from floatwindow.
Related Issues (20)
- 横屏靠右,切换横竖靠右 有问题 HOT 1
- androidP 9.0 悬浮权限无法申请
- 可以不申请权限使用吗
- 可以不申请权限吗 HOT 2
- 自定义布局存在把悬浮窗拖到边缘位置,里面有控件的情况下拖不动,因为里面的组件把事件拿走了
- FloatWindow of this tag has been added
- 被拖出去了,怎么办呀
- 设置自定义布局动画啊无效
- 当前Activity不在显示列表中,点击Home后如何显示?
- 悬浮窗中的edittext无法弹出输入法 HOT 1
- 应用打开权限页面时用户直接返回应用,再次调用代码块时出错
- setDesktopShow(false),返回后,闪一下就消失了 HOT 1
- 根布局view
- 点击事件怎么设置呢 HOT 4
- 进入APP不显示 ,然后我点击就显示,后台通知显示
- 不需要权限的悬浮窗方案了解一下~
- hasPermissionForO在8.0实际无效
- 我发现我的点击事件也不能设置emm
- 作者貌似弃坑了,推荐另外一款悬浮窗框架 HOT 1
- 重启app后不显示的问题,设置左面显示未true,不想要桌面显示的效果可以在ondestory销毁就可以了
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from floatwindow.