Firefly开源社区
标题:
[风之空响]firefly 如何在应用中隐藏状态栏(7.×未测试)
[打印本页]
作者:
风之空响
时间:
2017-6-21 10:24
标题:
[风之空响]firefly 如何在应用中隐藏状态栏(7.×未测试)
import android.app.Activity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.os.Build;
import android.view.View.OnSystemUiVisibilityChangeListener;
import android.content.pm.ActivityInfo;
import android.util.Log;
public class FullscreenActivity extends Activity implements OnSystemUiVisibilityChangeListener {
private static final int SYSTEM_UI_FLAG_SHOW_FULLSCREEN = 0x00000008; //View.SYSTEM_UI_FLAG_SHOW_FULLSCREEN
@Override
protected void onCreate(Bundle savedInstanceState) {
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_FULLSCREEN);
getWindow().getDecorView().setSystemUiVisibility(SYSTEM_UI_FLAG_SHOW_FULLSCREEN);
getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(this);
hideSystemUI();
super.onCreate(savedInstanceState);
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
hideSystemUI();
}
}
@Override
public void onSystemUiVisibilityChange(int visibility) {
hideSystemUI();
}
private void hideSystemUI()
{
getWindow().getDecorView().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);
}
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
int km = KeyEvent.KEYCODE_MENU;
if(keyCode==KeyEvent.KEYCODE_MENU){
return true ;
}
return super.onKeyDown(keyCode, event);
}
}
复制代码
作者:
大头fx
时间:
2017-6-21 16:28
用沉浸式状态栏就行
作者:
华夏¥熊猫仔
时间:
2018-1-4 08:51
这个隐藏了,用户还是可以上滑下就出来的,有什么办法固死么
作者:
?_S9mm1
时间:
2018-11-6 13:49
正好有这个需求
欢迎光临 Firefly开源社区 (https://dev.t-firefly.com/)
Powered by Discuz! X3.1