Java Code Examples for android.view.View#setFitsSystemWindows()
The following examples show how to use
android.view.View#setFitsSystemWindows() .
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: CrazyDaily File: MainActivity.java License: Apache License 2.0 | 6 votes |
private void handleTranslucent() { Window window = getWindow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.setNavigationBarColor(Color.WHITE); } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } ViewGroup parent = (ViewGroup) findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 2
Source Project: ImmersionBar File: ImmersionBar.java License: Apache License 2.0 | 6 votes |
private static void setFitsSystemWindows(View view, boolean applySystemFits) { if (view == null) { return; } if (view instanceof ViewGroup) { ViewGroup viewGroup = (ViewGroup) view; if (viewGroup instanceof DrawerLayout) { setFitsSystemWindows(viewGroup.getChildAt(0), applySystemFits); } else { viewGroup.setFitsSystemWindows(applySystemFits); viewGroup.setClipToPadding(true); } } else { view.setFitsSystemWindows(applySystemFits); } }
Example 3
Source Project: MNImageBrowser File: ImmersionBar.java License: GNU General Public License v3.0 | 6 votes |
/** * 解决顶部与布局重叠问题 * Sets fits system windows. * * @param activity the activity */ public static void setFitsSystemWindows(Activity activity) { if (activity == null) { return; } ViewGroup parent = activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { if (childView instanceof DrawerLayout) { continue; } childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 4
Source Project: CrazyDaily File: PhotoActivity.java License: Apache License 2.0 | 6 votes |
/** * 处理状态栏透明 */ private void handleStatusbarTransparent() { final Window window = getWindow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); window.setStatusBarColor(Color.TRANSPARENT); } else { window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); } ViewGroup content = findViewById(android.R.id.content); for (int i = 0, count = content.getChildCount(); i < count; i++) { View child = content.getChildAt(i); if (child instanceof ViewGroup) { child.setFitsSystemWindows(true); ((ViewGroup) child).setClipToPadding(false); } } FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mPhotoDrawer.getLayoutParams(); params.topMargin = -DeviceUtil.getStatusBarHeight(this); mPhotoDrawer.setLayoutParams(params); }
Example 5
Source Project: Dashchan File: DialogStack.java License: Apache License 2.0 | 5 votes |
public static void bindDialogToExpandedScreen(Dialog dialog, View rootView, ExpandedScreen expandedScreen) { ViewGroup decorView = (ViewGroup) dialog.getWindow().getDecorView(); decorView.getChildAt(0).setFitsSystemWindows(false); // Fix resizing dialogs when status bar in gallery becomes hidden with expanded screen enabled if (expandedScreen.isFullScreenLayoutEnabled()) { expandedScreen.addAdditionalView(rootView, false); decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION); dialog.setOnDismissListener(d -> expandedScreen.removeAdditionalView(rootView)); expandedScreen.updatePaddings(); } else { rootView.setFitsSystemWindows(true); } }
Example 6
Source Project: VRPlayer File: StatusBarUtil.java License: Apache License 2.0 | 5 votes |
/** * 设置根布局参数 */ private static void setRootView(Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 7
Source Project: MNProgressHUD File: StatusBarUtil.java License: Apache License 2.0 | 5 votes |
/** * 设置根布局参数 */ private static void setRootView(Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 8
Source Project: tysq-android File: BitToolbarActivity.java License: GNU General Public License v3.0 | 5 votes |
/** * 初始化toolbar */ private void initToolbar() { // 获取 DecorView ViewGroup decorView = (ViewGroup) getWindow().getDecorView(); // 获取到 TitleView ViewGroup viewGroup = (ViewGroup) decorView.getChildAt(0); if (viewGroup instanceof LinearLayout) { View toolbar = LayoutInflater.from(this).inflate(BitManager.getInstance().getToolbarLayout(), null, false); viewGroup.addView(toolbar, 0); this.mToolbar = toolbar.findViewById(R.id.toolbar); setSupportActionBar(this.mToolbar); if (getSupportActionBar() != null) { //隐藏标题 getSupportActionBar().setDisplayShowTitleEnabled(false); //显示回退按钮 getSupportActionBar().setDisplayHomeAsUpEnabled(true); } ViewGroup contentFrameLayout = findViewById(Window.ID_ANDROID_CONTENT); View parentView = contentFrameLayout.getChildAt(0); if (parentView != null) { parentView.setFitsSystemWindows(true); } } }
Example 9
Source Project: stynico File: StatusBarUtil.java License: MIT License | 5 votes |
/** * 设置根布局参数 */ private static void setRootView(Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 10
Source Project: googlecalendar File: MainActivity.java License: Apache License 2.0 | 5 votes |
private static void setRootView(Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(false); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 11
Source Project: imsdk-android File: StatusBarUtil.java License: MIT License | 5 votes |
/** * 设置根布局参数 */ private static void setRootView(Activity activity) { ViewGroup parent = activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 12
Source Project: StatusBarManager File: StatusBarUtil.java License: Apache License 2.0 | 5 votes |
/** * 设置根布局参数 */ private static void setRootView(Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 13
Source Project: Focus File: StatusBarUtil.java License: GNU General Public License v3.0 | 5 votes |
/** * 设置根布局参数 */ private static void setRootView(Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 14
Source Project: AndroidUiKit File: ImmersiveModeUtil.java License: Apache License 2.0 | 5 votes |
/** * 设置根布局参数 */ private static void setRootView(Activity activity) { ViewGroup parent = activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 15
Source Project: MvpRoute File: StatusBarUtils.java License: Apache License 2.0 | 5 votes |
/** * 设置让内容显示在状态栏之下 * * @param activity */ public static void fitWindowAndClipPadding(@NonNull final Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 16
Source Project: iGap-Android File: StatusBarUtil.java License: GNU Affero General Public License v3.0 | 5 votes |
private static void setRootView(Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 17
Source Project: MyBookshelf File: ImmersionBar.java License: GNU General Public License v3.0 | 5 votes |
/** * 解决顶部与布局重叠问题 * Sets fits system windows. * * @param activity the activity */ public static void setFitsSystemWindows(Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 18
Source Project: AndroidPicker File: StatusBarUtil.java License: MIT License | 5 votes |
/** * 设置根布局参数 */ private static void setRootView(Activity activity) { ViewGroup parent = (ViewGroup) activity.findViewById(android.R.id.content); for (int i = 0, count = parent.getChildCount(); i < count; i++) { View childView = parent.getChildAt(i); if (childView instanceof ViewGroup) { childView.setFitsSystemWindows(true); ((ViewGroup) childView).setClipToPadding(true); } } }
Example 19
Source Project: lbry-android File: MainActivity.java License: MIT License | 4 votes |
public void unsetFitsSystemWindows(View view) { view.setFitsSystemWindows(false); }
Example 20
Source Project: SwipeBack File: ModSDK21.java License: GNU General Public License v3.0 | 4 votes |
@TargetApi(21) public static void afterOnPostCreateSDK21(XC_MethodHook.MethodHookParam mhparams) throws Throwable { Class<?> internalStyleable = findClass("com.android.internal.R.styleable", null); int[] internalTheme = $(getStaticObjectField(internalStyleable, "Theme")); int internalColorPrimary = getStaticIntField(internalStyleable, "Theme_colorPrimaryDark"); SwipeBackActivityHelper helper = $(getAdditionalInstanceField(mhparams.thisObject, "helper")); if (helper != null) { final Activity activity = $(mhparams.thisObject); String packageName = activity.getApplicationInfo().packageName; String className = activity.getClass().getName(); mSettings.reload(); if (!mSettings.getBoolean(packageName, className, Settings.LOLLIPOP_HACK, false)) return; ViewGroup root = $(helper.getSwipeBackLayout().getChildAt(0)); View content = root.getChildAt(0); final WindowInsetsColorDrawable bkg = new WindowInsetsColorDrawable(content.getBackground()); content.setBackground(bkg); TypedArray a = activity.getTheme().obtainStyledAttributes(internalTheme); int primary = a.getColor(internalColorPrimary, 0); a.recycle(); if (primary != 0) { bkg.setTopDrawable(new ColorDrawable(primary)); } else { content.setSystemUiVisibility(content.getSystemUiVisibility() | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN); content.setFitsSystemWindows(true); } root.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() { @Override public WindowInsets onApplyWindowInsets(View v, WindowInsets insets) { bkg.setTopInset(insets.getSystemWindowInsetTop()); activity.getWindow().setStatusBarColor(0); return insets; } }); } }