@NonNull
public static FrameLayout getRootFrame(@NonNull Activity activity) {
View re = activity.findViewById(android.R.id.content);
if (re != null && re instanceof FrameLayout) {
return (FrameLayout) re;
}
ViewGroup viewGroup = (ViewGroup) activity.getWindow().getDecorView();
re = viewGroup.getChildAt(viewGroup.getChildCount() - 1);
if (re != null && re instanceof FrameLayout) {
return (FrameLayout) re;
} else {
re = new FrameLayout(activity);
activity.getActionBar().getHeight();
ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT
, ViewGroup.LayoutParams.MATCH_PARENT);
viewGroup.addView(re, lp);
return (FrameLayout) re;
}
}