Enable appearence on Window after setFlags on Android/Cordova

荒凉一梦 提交于 2019-12-10 18:34:25

问题


I'm developing my first Cordova plugin as a means to learn Cordova better. I'm however stock and hope you guys can help with the last bits.

The source can be found at https://github.com/dotnetCarpenter/cordova-plugins/tree/master/FullscreenPlugin

The aim is to develop a full screen plugin which can toggle between states. As shown here at SO, it should only be three lines.

requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
  WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.main);

Which translated to Cordova would be:

Activity activity = this.cordova.getActivity();
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
activity.getWindow()
 .setFlags(
 WindowManager.LayoutParams.FLAG_FULLSCREEN,
 WindowManager.LayoutParams.FLAG_FULLSCREEN
 );
activity.setContentView(R.layout.main);

R.layout.main gave me all kinds of trouble. Maybe because I'm missing something in my plugin.xml. I'm not sure. Anyway, after finding a post about toggling full screen. I figured I change the last line to:

activity.getCurrentFocus().requestLayout();

Unfortunately to no avail. I have tested a bunch of different setups, including this.webView.requestLayout();, but have reached my end. I'm stuck!

I would appreciate if anyone could point me in the right direction.

Cheers, Jon

来源:https://stackoverflow.com/questions/20005746/enable-appearence-on-window-after-setflags-on-android-cordova

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!