Panel Overlaps Status Bar When Activity Has A Translucent Status Bar Theme
Created by: rabyunghwa
Hey. My activity(which has a fragment) has a translucent status bar theme. The problem is inside this fragment when tapped, the panel would slide all the way up to overlap the status bar. So how to solve this so that when expanded, the panel would still appear right below the status bar? What I have tried so far is to dynamically change the system window flags in onPanelExpanded() and onPanelCollapsed() by setting and clearing the translucent ones. But this approach has some issues. The activity would be pushed down below the status bar. I've also tried setting the anchor point. But still there is a problem. Here is the code snippet:
@Override
public void onPanelExpanded(View panel) {
Log.i(TAG, "onPanelExpanded");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window w = getWindow(); // in Activity's onCreate() for instance
w.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}
@Override
public void onPanelCollapsed(View panel) {
Log.i(TAG, "onPanelCollapsed");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window w = getWindow(); // in Activity's onCreate() for instance
w.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
}