我有一个App和SDK,两者都不同。我将SDK包含在我的应用程序中。现在问题是我在全屏幕上进行活动时遇到问题。在SDK中,类是NON-Activity类,没有GUI,只有后端Process。所以我想让他们全屏视图。在这里我不能使用:
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
因为我的活动非活动类所以没有窗口。所以计划使用此代码,
ws.setJavaScriptEnabled(true);
htmlAd.addJavascriptInterface(new Object()
{
@JavascriptInterface
public void performClick(String strl)
{
Activity activity = (Activity) adViewContext;
if(strl.equals("base")){
View mDecorView = activity.getWindow().getDecorView();
Toast.makeText (activity, "ONE" + strl, Toast.LENGTH_SHORT).show();
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}else{
View mDecorView = activity.getWindow().getDecorView();
Toast.makeText (activity, "TWO" + strl, Toast.LENGTH_SHORT).show();
mDecorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
}
}, "ok");
但它不起作用,请指导我。
答案 0 :(得分:1)
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
adjustFullScreen(newConfig);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
adjustFullScreen(getResources().getConfiguration());
}
}
private void adjustFullScreen(Configuration config) {
final View decorView = getWindow().getDecorView();
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
decorView.setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
} else {
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
}
答案 1 :(得分:0)
将您的应用程序级主题更改为
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/>