Giter Site home page Giter Site logo

Comments (5)

chenfd99 avatar chenfd99 commented on July 20, 2024 1

我今天闲来有空 研究了一下怎么按需求创建并显示悬浮窗
首先把库下载下来
修改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.

chenfd99 avatar chenfd99 commented on July 20, 2024

我也发现了这个问题

from floatwindow.

chenfd99 avatar chenfd99 commented on July 20, 2024

是这样的 如果在onCreate里初始化界面呢 悬浮窗就会显示 当在按钮的setOnClickListener 里初始化呢 就需要第二次进入才会显示悬浮窗

from floatwindow.

songlongkuan avatar songlongkuan commented on July 20, 2024

好神奇

from floatwindow.

yhaolpz avatar yhaolpz commented on July 20, 2024

悬浮窗的设计初衷用于多 Activity 显示,我当初的思路是在 Application 中创建这个“全局视图”,所以代码逻辑是在 Activity Resumed 时才会处理悬浮窗的显示与否,但是这一全局视图可能在某个Activity 中才会设置开启,针对这种情况可以在初始化后紧接着调用
FloatWindow.get().show();
即可。

from floatwindow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.