Java Code Examples for android.view.WindowManager
The following examples show how to use
android.view.WindowManager. 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: AndroidDesignPreview Source File: DesktopViewerActivity.java License: Apache License 2.0 | 8 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { // Pre-Honeycomb this is the best we can do. getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } setContentView(R.layout.main); mStatusTextView = (TextView) findViewById(R.id.status_text); mTargetView = findViewById(R.id.target); mTargetView.setOnTouchListener(mTouchListener); mTargetView.getViewTreeObserver().addOnGlobalLayoutListener(this); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { mSystemUiHider = new SystemUiHider(mTargetView); mSystemUiHider.setup(getWindow()); } else { getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }
Example 2
Source Project: AirFree-Client Source File: CaptureActivity.java License: GNU General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle icicle) { requestWindowFeature(Window.FEATURE_NO_TITLE); super.onCreate(icicle); Window window = getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(R.layout.activity_capture); scanPreview = (SurfaceView) findViewById(R.id.capture_preview); scanContainer = (RelativeLayout) findViewById(R.id.capture_container); scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view); scanLine = (ImageView) findViewById(R.id.capture_scan_line); inactivityTimer = new InactivityTimer(this); beepManager = new BeepManager(this); TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.9f); animation.setDuration(4500); animation.setRepeatCount(-1); animation.setRepeatMode(Animation.RESTART); scanLine.startAnimation(animation); }
Example 3
Source Project: JCVideoPlayer Source File: JCVideoPlayer.java License: MIT License | 6 votes |
@Override public void onCompletion() { setUiWitStateAndScreen(CURRENT_STATE_NORMAL); if (textureViewContainer.getChildCount() > 0) { textureViewContainer.removeAllViews(); } JCVideoPlayerManager.setListener(null);//这里还不完全, // JCVideoPlayerManager.setLastListener(null); JCMediaManager.instance().currentVideoWidth = 0; JCMediaManager.instance().currentVideoHeight = 0; AudioManager mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE); mAudioManager.abandonAudioFocus(onAudioFocusChangeListener); JCUtils.scanForActivity(getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); clearFullscreenLayout(); }
Example 4
Source Project: juda Source File: IntroActivity.java License: GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); addSlide(new Slide1Fragment()); addSlide(new Slide2Fragment()); addSlide(new Slide3Fragment()); addSlide(new Slide4Fragment()); showSkipButton(false); askForPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 3); }
Example 5
Source Project: 30-android-libraries-in-30-days Source File: Engine.java License: Apache License 2.0 | 6 votes |
/** * @return <code>true</code> when the sensor was successfully enabled, <code>false</code> otherwise. */ public boolean enableAccelerationSensor(final Context pContext, final IAccelerationListener pAccelerationListener, final AccelerationSensorOptions pAccelerationSensorOptions) { final SensorManager sensorManager = (SensorManager) pContext.getSystemService(Context.SENSOR_SERVICE); if(Engine.isSensorSupported(sensorManager, Sensor.TYPE_ACCELEROMETER)) { this.mAccelerationListener = pAccelerationListener; if(this.mAccelerationData == null) { final Display display = ((WindowManager) pContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); final int displayRotation = display.getOrientation(); this.mAccelerationData = new AccelerationData(displayRotation); } this.registerSelfAsSensorListener(sensorManager, Sensor.TYPE_ACCELEROMETER, pAccelerationSensorOptions.getSensorDelay()); return true; } else { return false; } }
Example 6
Source Project: 365browser Source File: NativePageDialog.java License: Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); FrameLayout view = (FrameLayout) LayoutInflater.from(getContext()).inflate( R.layout.dialog_with_titlebar, null); view.addView(mPage.getView(), 0); setContentView(view); getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); TextView title = (TextView) view.findViewById(R.id.title); title.setText(mPage.getTitle()); ImageButton closeButton = (ImageButton) view.findViewById(R.id.close_button); closeButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); }
Example 7
Source Project: BottomNavigationBar Source File: MainActivity.java License: Apache License 2.0 | 6 votes |
private boolean hasSystemNavigationBar() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); DisplayMetrics realDisplayMetrics = new DisplayMetrics(); d.getRealMetrics(realDisplayMetrics); int realHeight = realDisplayMetrics.heightPixels; int realWidth = realDisplayMetrics.widthPixels; DisplayMetrics displayMetrics = new DisplayMetrics(); d.getMetrics(displayMetrics); int displayHeight = displayMetrics.heightPixels; int displayWidth = displayMetrics.widthPixels; return (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0; } else { boolean hasMenuKey = ViewConfiguration.get(this).hasPermanentMenuKey(); boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK); return !hasMenuKey && !hasBackKey; } }
Example 8
Source Project: LeisureRead Source File: SystemUiVisibilityUtil.java License: Apache License 2.0 | 6 votes |
/** * * 显示或隐藏StatusBar * * @param enable false 显示,true 隐藏 */ public static void hideStatusBar(Window window, boolean enable) { WindowManager.LayoutParams p = window.getAttributes(); if (enable) //|=:或等于,取其一 { p.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN; } else //&=:与等于,取其二同时满足, ~ : 取反 { p.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN); } window.setAttributes(p); window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS); }
Example 9
Source Project: android-hidden-camera Source File: HiddenCameraService.java License: Apache License 2.0 | 6 votes |
/** * Add camera preview to the root of the activity layout. * * @return {@link CameraPreview} that was added to the view. */ private CameraPreview addPreView() { //create fake camera view CameraPreview cameraSourceCameraPreview = new CameraPreview(this, this); cameraSourceCameraPreview.setLayoutParams(new ViewGroup .LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(1, 1, Build.VERSION.SDK_INT < Build.VERSION_CODES.O ? WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY : WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT); mWindowManager.addView(cameraSourceCameraPreview, params); return cameraSourceCameraPreview; }
Example 10
Source Project: YCProgress Source File: CarlProgressbar.java License: Apache License 2.0 | 6 votes |
private void initView(Context context) { mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); mLayoutParams = new WindowManager.LayoutParams(); mLayoutParams.gravity = Gravity.START | Gravity.TOP; mLayoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT; mLayoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT; mLayoutParams.format = PixelFormat.TRANSLUCENT; mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) { mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION; } else { mLayoutParams.type = WindowManager.LayoutParams.TYPE_TOAST; } }
Example 11
Source Project: Android-Application-ZJB Source File: UserTextDialog.java License: Apache License 2.0 | 6 votes |
/** * 初始化 */ private void init() { // 弹出自定义dialog LayoutInflater inflater = LayoutInflater.from(getContext()); View view = inflater.inflate(R.layout.dlg_user_text, null); // 对话框 getWindow().setBackgroundDrawable(new ColorDrawable(0)); requestWindowFeature(Window.FEATURE_NO_TITLE); // 设置宽度为屏幕的宽度 WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.width = 666; // 设置宽度 getWindow().setAttributes(lp); getWindow().setContentView(view); setCancelable(false); ButterKnife.inject(this); }
Example 12
Source Project: AndroidAPS Source File: InsightAlertActivity.java License: GNU Affero General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_insight_alert); bindService(new Intent(this, InsightAlertService.class), serviceConnection, BIND_AUTO_CREATE); icon = findViewById(R.id.icon); errorCode = findViewById(R.id.error_code); errorTitle = findViewById(R.id.error_title); errorDescription = findViewById(R.id.error_description); mute = findViewById(R.id.mute); confirm = findViewById(R.id.confirm); setFinishOnTouchOutside(false); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); }
Example 13
Source Project: MeiBaseModule Source File: Eyes.java License: Apache License 2.0 | 6 votes |
/** * 设置状态栏图标为深色和魅族特定的文字风格,Flyme4.0以上 */ static boolean FlymeSetStatusBarLightMode(Activity activity, boolean darkmode) { boolean result = false; try { WindowManager.LayoutParams lp = activity.getWindow().getAttributes(); Field darkFlag = WindowManager.LayoutParams.class .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); Field meizuFlags = WindowManager.LayoutParams.class .getDeclaredField("meizuFlags"); darkFlag.setAccessible(true); meizuFlags.setAccessible(true); int bit = darkFlag.getInt(null); int value = meizuFlags.getInt(lp); if (darkmode) { value |= bit; } else { value &= ~bit; } meizuFlags.setInt(lp, value); activity.getWindow().setAttributes(lp); result = true; } catch (Exception e) { e.printStackTrace(); } return result; }
Example 14
Source Project: FastAndroid Source File: UIStatusBarController.java License: Apache License 2.0 | 6 votes |
/** * OPPOAndroid系统 * https://open.oppomobile.com/wiki/index#id=73494 */ public static void setStatusBarOppo(@NonNull Activity activity, boolean lightMode) { int SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT = 0x00000010; Window window = activity.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.getDecorView().setSystemUiVisibility(SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT); int vis = window.getDecorView().getSystemUiVisibility(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (lightMode) { vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } else { vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (lightMode) { vis |= SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT; } else { vis &= ~SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT; } } window.getDecorView().setSystemUiVisibility(vis); }
Example 15
Source Project: BaseAndroidApp Source File: AdjustStatusbar.java License: Apache License 2.0 | 6 votes |
@TargetApi (Build.VERSION_CODES.KITKAT) public static void addColorAndHeight(@NonNull Activity activity) { if (!activity.getResources() .getBoolean(R.bool.should_color_status_bar)) { return; } View statusBar = activity.findViewById(R.id.statusBarBackground); if (statusBar == null) { return; } Window window = activity.getWindow(); window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); int statusBarHeight = getStatusBarHeight(activity); if (statusBarHeight != 0) { final int color = ContextCompat.getColor(activity, R.color.primary_dark); statusBar.getLayoutParams().height = +statusBarHeight; statusBar.setBackgroundColor(color); statusBar.setVisibility(View.VISIBLE); } else { statusBar.setVisibility(View.GONE); } }
Example 16
Source Project: WanAndroid Source File: DisplayUtils.java License: MIT License | 6 votes |
public static int getDpi(Context context){ int dpi = 0; WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = windowManager.getDefaultDisplay(); DisplayMetrics displayMetrics = new DisplayMetrics(); @SuppressWarnings("rawtypes") Class c; try { c = Class.forName("android.view.Display"); @SuppressWarnings("unchecked") Method method = c.getMethod("getRealMetrics",DisplayMetrics.class); method.invoke(display, displayMetrics); dpi=displayMetrics.heightPixels; }catch(Exception e){ e.printStackTrace(); } return dpi; }
Example 17
Source Project: iGap-Android Source File: ActivityRatingBar.java License: GNU Affero General Public License v3.0 | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { G.isShowRatingDialog = true; getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON); super.onCreate(savedInstanceState); setContentView(R.layout.activity_rating_bar); id = getIntent().getExtras().getLong(ID_EXTRA); initComponent(); }
Example 18
Source Project: browser Source File: AppBaseActivity.java License: GNU General Public License v2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //PushAgent.getInstance(this).onAppStart(); MobclickAgent.openActivityDurationTrack(false); getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN ); mBaseActivity.init(getBaseContext(), this); onActivityInit(); LogUtil.d(TAG, "checktask onCreate:" + super.getClass().getSimpleName() + "#0x" + super.hashCode() + ", taskid:" + getTaskId() + ", task:" + new ActivityTaskUtils(this)); abstracrRegist(); getTopBarView().showSearch(hasSearch()); }
Example 19
Source Project: Nimingban Source File: TypeSendFragment.java License: Apache License 2.0 | 6 votes |
@Override public void onDestroyView() { super.onDestroyView(); if (mPreview != null && mImagePreview != null && mEditText != null) { clearImagePreview(); } if (mNMBRequest != null) { mNMBRequest.cancel(); mNMBRequest = null; } // Hide ime keyboard View view = getActivity().getCurrentFocus(); if (view != null) { InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(view.getWindowToken(), 0); } // Cancel FLAG_ALT_FOCUSABLE_IM getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); }
Example 20
Source Project: StatusBarUtil Source File: StatusBarUtil.java License: Apache License 2.0 | 6 votes |
/** * 设置Flyme4+的状态栏的darkMode,darkMode时候字体颜色及icon * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI * * @param window 目标window * @param dark 亮色 or 暗色 */ private static void setModeForFlyme4(Window window, boolean dark) { try { WindowManager.LayoutParams lp = window.getAttributes(); Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags"); darkFlag.setAccessible(true); meizuFlags.setAccessible(true); int bit = darkFlag.getInt(null); int value = meizuFlags.getInt(lp); if (dark) { value |= bit; } else { value &= ~bit; } meizuFlags.setInt(lp, value); window.setAttributes(lp); } catch (Exception e) { Log.e("StatusBar", "darkIcon: failed"); } }
Example 21
Source Project: TinyDancer Source File: TinyCoach.java License: MIT License | 6 votes |
public TinyCoach(Application context, FPSConfig config) { fpsConfig = config; //create meter view meterView = (TextView) LayoutInflater.from(context).inflate(R.layout.meter_view, null); //set initial fps value....might change... meterView.setText((int) fpsConfig.refreshRate + ""); // grab window manager and add view to the window windowManager = (WindowManager) meterView.getContext().getSystemService(Service.WINDOW_SERVICE); int minWidth = meterView.getLineHeight() + meterView.getTotalPaddingTop() + meterView.getTotalPaddingBottom() + (int) meterView.getPaint().getFontMetrics().bottom; meterView.setMinWidth(minWidth); addViewToWindow(meterView); }
Example 22
Source Project: android_9.0.0_r45 Source File: DreamService.java License: Apache License 2.0 | 5 votes |
private void applyWindowFlags(int flags, int mask) { if (mWindow != null) { WindowManager.LayoutParams lp = mWindow.getAttributes(); lp.flags = applyFlags(lp.flags, flags, mask); mWindow.setAttributes(lp); mWindow.getWindowManager().updateViewLayout(mWindow.getDecorView(), lp); } }
Example 23
Source Project: ViewDebugHelper Source File: MyWindowManager.java License: BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * 将小悬浮窗从屏幕上移除。 * * @param context * 必须为应用程序的Context. */ public static void removeFloatWindow(Context context) { if (mFloatWindow != null) { WindowManager windowManager = getWindowManager(context); windowManager.removeView(mFloatWindow); mFloatWindow = null; } }
Example 24
Source Project: Telegram Source File: PhotoAlbumPickerActivity.java License: GNU General Public License v2.0 | 5 votes |
private void fixLayoutInternal() { if (getParentActivity() == null) { return; } WindowManager manager = (WindowManager) ApplicationLoader.applicationContext.getSystemService(Activity.WINDOW_SERVICE); int rotation = manager.getDefaultDisplay().getRotation(); columnsCount = 2; if (!AndroidUtilities.isTablet() && (rotation == Surface.ROTATION_270 || rotation == Surface.ROTATION_90)) { columnsCount = 4; } listAdapter.notifyDataSetChanged(); }
Example 25
Source Project: Taskbar Source File: AbstractSelectAppActivity.java License: Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boolean noShadow = getIntent().hasExtra("no_shadow"); setContentView(R.layout.tb_desktop_icon_select_app); setFinishOnTouchOutside(false); setTitle(getString(R.string.tb_select_an_app)); if(noShadow) { WindowManager.LayoutParams params = getWindow().getAttributes(); params.dimAmount = 0; getWindow().setAttributes(params); if(U.isChromeOs(this) && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) getWindow().setElevation(0); } SharedPreferences pref = U.getSharedPreferences(this); isCollapsed = !pref.getBoolean(PREF_COLLAPSED, false); if(!isCollapsed) { U.sendBroadcast(this, ACTION_HIDE_TASKBAR); } progressBar = findViewById(R.id.progress_bar); appList = findViewById(R.id.list); appListGenerator = new DesktopIconAppListGenerator(); appListGenerator.execute(); }
Example 26
Source Project: cast-videos-android Source File: LocalPlayerActivity.java License: Apache License 2.0 | 5 votes |
@SuppressLint("NewApi") @Override public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); getSupportActionBar().show(); if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); } updateMetadata(false); mContainer.setBackgroundColor(getResources().getColor(R.color.black)); } else { getWindow().setFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN, WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); getWindow().clearFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE); } updateMetadata(true); mContainer.setBackgroundColor(getResources().getColor(R.color.white)); } }
Example 27
Source Project: Android-Application-ZJB Source File: BaseActivity.java License: Apache License 2.0 | 5 votes |
/** * If the Android version is higher than KitKat(API>=19) <br> use this call to show & hide * * @param enable */ @SuppressLint("NewApi") public final void makeFullScreenAfterKitKat(boolean enable) { try { View decorView = getWindow().getDecorView(); if (enable) { int uiOptionsEnable = 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; decorView.setSystemUiVisibility(uiOptionsEnable); } else { int uiOptionsDisable = View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; decorView.setSystemUiVisibility(uiOptionsDisable); } } catch (Exception e) { WindowManager.LayoutParams lp = getWindow().getAttributes(); if (enable) { lp.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY; } else { lp.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY); } getWindow().setAttributes(lp); } }
Example 28
Source Project: rebootmenu Source File: UIUtils.java License: GNU General Public License v3.0 | 5 votes |
/** * 使状态栏透明 * 来自https://github.com/laobie/StatusBarUtil * * @param activity 要渲染的活动 */ @TargetApi(Build.VERSION_CODES.LOLLIPOP) public static void transparentStatusBar(@NonNull Activity activity) { new DebugLog("transparentStatusBar", DebugLog.LogLevel.V); Window window = activity.getWindow(); 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); }
Example 29
Source Project: Infinity-For-Reddit Source File: SetAsWallpaperAsyncTask.java License: GNU Affero General Public License v3.0 | 5 votes |
public SetAsWallpaperAsyncTask(Bitmap bitmap, int setTo, WallpaperManager manager, WindowManager windowManager, WallpaperSetter.SetWallpaperListener setWallpaperListener) { this.bitmap = bitmap; this.setTo = setTo; this.manager = manager; this.windowManager = windowManager; this.setWallpaperListener = setWallpaperListener; }
Example 30
Source Project: monolog-android Source File: AbstractActivity.java License: MIT License | 5 votes |
/** * 小米的沉浸式控制 * @param on */ @TargetApi(19) protected void setTranslucentStatus(boolean on) { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }