Android Disable Overlay Of Actionbar And Navigationbar For Flag_translucent
As you can see by the picture the navigationbar and the statusbar is overlaying the layout. All I have done is if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
Solution 1:
Are you using a custom theme that does this? Such a setting android:windowActionBarOverlay
to true?
If so, disable that in the theme.
Source: http://developer.android.com/training/basics/actionbar/overlaying.html
Solution 2:
I believe you're trying to put your application in Immersive Mode. If so, this is the code I found from Google,which will put your app in immersive mode and on touch will show the Status bar and Navigation Bar.
publicclassImmersiveActivityextendsActivity {
privatestaticfinalintINITIAL_HIDE_DELAY=300;
private View mDecorView;
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.immersive_activity);
finalViewcontrolsView= findViewById(R.id.fullscreen_content_controls);
finalViewcontentView= findViewById(R.id.fullscreen_content);
mDecorView = getWindow().getDecorView();
mDecorView.setOnSystemUiVisibilityChangeListener(
newView.OnSystemUiVisibilityChangeListener() {
@OverridepublicvoidonSystemUiVisibilityChange(int flags) {
booleanvisible= (flags & View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
controlsView.animate()
.alpha(visible ? 1 : 0)
.translationY(visible ? 0 : controlsView.getHeight());
}
});
contentView.setClickable(true);
finalGestureDetectorclickDetector=newGestureDetector(this,
newGestureDetector.SimpleOnGestureListener() {
@OverridepublicbooleanonSingleTapUp(MotionEvent e) {
booleanvisible= (mDecorView.getSystemUiVisibility()
& View.SYSTEM_UI_FLAG_HIDE_NAVIGATION) == 0;
if (visible) {
hideSystemUI();
} else {
showSystemUI();
}
returntrue;
}
});
contentView.setOnTouchListener(newView.OnTouchListener() {
@OverridepublicbooleanonTouch(View view, MotionEvent motionEvent) {
return clickDetector.onTouchEvent(motionEvent);
}
});
showSystemUI();
}
@OverridepublicvoidonWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
// When the window loses focus (e.g. the action overflow is shown),// cancel any pending hide action. When the window gains focus,// hide the system UI.if (hasFocus) {
delayedHide(INITIAL_HIDE_DELAY);
} else {
mHideHandler.removeMessages(0);
}
}
privatevoidhideSystemUI() {
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
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_LOW_PROFILE
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
privatevoidshowSystemUI() {
mDecorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
}
privatefinalHandlermHideHandler=newHandler() {
@OverridepublicvoidhandleMessage(Message msg) {
hideSystemUI();
}
};
privatevoiddelayedHide(int delayMillis) {
mHideHandler.removeMessages(0);
mHideHandler.sendEmptyMessageDelayed(0, delayMillis);
}
}
Post a Comment for "Android Disable Overlay Of Actionbar And Navigationbar For Flag_translucent"