Giter VIP home page Giter VIP logo

Comments (5)

Petterpx avatar Petterpx commented on June 4, 2024

参考主页以下方式创建悬浮窗,在安卓11上没有任何效果,机型 redmi k2o pro ,辛苦支持

AppHelper helper = AppHelper.builder() .setLayout(R.layout.item_floating) .setLayoutView(view) .enableFx() .build(); FloatingX.init(helper);

先说结论,建议您调用一下FloatingX.control().show();

再说原因:
setLayout与setLayoutView二选一即可,具体使用谁取决于两个方法谁时最后被调用的。
您的代码应该不是在Application中被调用,您可以将上述代码移动到Application-onCreate里,然后根据您的需要选择setLayout 或者 setLayoutView,浮窗将在 init初始化后正常显示。
如果非Application,建议您init初始化后,调用show()方法进行显示。

from floatingx.

Petterpx avatar Petterpx commented on June 4, 2024

参考主页以下方式创建悬浮窗,在安卓11上没有任何效果,机型 redmi k2o pro ,辛苦支持

AppHelper helper = AppHelper.builder() .setLayout(R.layout.item_floating) .setLayoutView(view) .enableFx() .build(); FloatingX.init(helper);

还需要注意的是,因为您使用的是全局悬浮窗,如果要采用 setLayoutView 的方式,您需要保证这是一个application级的View,否则将存在内存泄漏问题。如果您没有太多需求,建议您使用setLayout的方式,由浮窗框架自行管理。

from floatingx.

gitcfly avatar gitcfly commented on June 4, 2024

from floatingx.

Petterpx avatar Petterpx commented on June 4, 2024

尝试了以下三种方式: 方式1:在Application中使用,无任何效果,代码如下: public class MyApplication extends Application { @OverRide public void onCreate() { super.onCreate(); AppHelper helper = AppHelper.builder() .setLayout(R.layout.float_layout) .enableFx() .build(); FloatingX.init(helper); FloatingX.control().show(); } } 方式2:在普通activity中使用:无任何效果,代码如下:public class MainActivity extends AppCompatActivity { private ActivityMainBinding binding; TessBaseAPI tessApi; @OverRide protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = ActivityMainBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); AppHelper helper = AppHelper.builder() .setLayout(R.layout.float_layout) .enableFx() .build(); FloatingX.init(helper); FloatingX.control().show(); } 方式三:在普通activity中使用,并通过按钮事件触发显示,终于出现了悬浮窗,但是仅仅为局部悬浮窗,应用退至后台运行后悬浮窗消失:public class MainActivity extends AppCompatActivity { private ActivityMainBinding binding; TessBaseAPI tessApi; @OverRide protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); binding = ActivityMainBinding.inflate(getLayoutInflater()); setContentView(binding.getRoot()); binding.showFloat.setOnClickListener(new View.OnClickListener() { @OverRide public void onClick(View view) { AppHelper helper = AppHelper.builder() .setLayout(R.layout.float_layout) .enableFx() .build(); FloatingX.init(helper); FloatingX.control().show(); } });}其中 float_layout.xml 内容如下: <?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:text="好吧,这是一个悬浮窗" /> </LinearLayout>请问下如何才能展示全局的悬浮窗呢

------------------ 原始邮件 ------------------ 发件人: "Petterpx/FloatingX" @.>; 发送时间: 2022年10月14日(星期五) 下午5:37 @.>; @.@.>; 主题: Re: [Petterpx/FloatingX] 在安卓11,机型redmi k2o pro上没有任何效果 (Issue #49) 参考主页以下方式创建悬浮窗,在安卓11上没有任何效果,机型 redmi k2o pro ,辛苦支持 AppHelper helper = AppHelper.builder() .setLayout(R.layout.item_floating) .setLayoutView(view) .enableFx() .build(); FloatingX.init(helper); 先说结论,建议您调用一下FloatingX.control().show(); 再说原因: setLayout与setLayoutView二选一即可,具体使用谁取决于两个方法谁时最后被调用的。 您的代码应该不是在Application中被调用,您可以将上述代码移动到Application-onCreate里,然后根据您的需要选择setLayout 或者 setLayoutView,浮窗将在 init初始化后正常显示。 如果非Application,建议您init初始化后,调用show()方法进行显示。 — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

感谢您的反馈,已经复现了该问题。另外因为这是免权限的悬浮窗,不支持在桌面展示,仅支持App内部。

from floatingx.

Petterpx avatar Petterpx commented on June 4, 2024

参考主页以下方式创建悬浮窗,在安卓11上没有任何效果,机型 redmi k2o pro ,辛苦支持

AppHelper helper = AppHelper.builder() .setLayout(R.layout.item_floating) .setLayoutView(view) .enableFx() .build(); FloatingX.init(helper);

您可以更新到1.0.7,即可修复此问题。推荐在Application中初始化。

from floatingx.

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.