Java Code Examples for android.app.Activity#requestWindowFeature()
The following examples show how to use
android.app.Activity#requestWindowFeature() .
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 File: UIHelper.java From coolreader with MIT License | 6 votes |
@SuppressLint("NewApi") public static void ToggleFullscreen(Activity activity, boolean fullscreen) { if (fullscreen) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar actionBar = activity.getActionBar(); if (actionBar != null) actionBar.hide(); } else { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); } activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); } else { activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN); activity.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } }
Example 2
Source File: ScreenUtils.java From DevUtils with Apache License 2.0 | 5 votes |
/** * 设置屏幕为全屏无标题 * <pre> * 需要在 setContentView 之前调用 * </pre> * @param activity {@link Activity} * @return {@code true} success, {@code false} fail */ public static boolean setFullScreenNoTitle(final Activity activity) { try { // 隐藏标题 activity.requestWindowFeature(Window.FEATURE_NO_TITLE); // 设置全屏 activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); // | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS return true; } catch (Exception e) { LogPrintUtils.eTag(TAG, e, "setFullScreenNoTitle"); } return false; }
Example 3
Source File: EditPage.java From -Android_ShareSDK_Example_Wechat with MIT License | 5 votes |
public void setActivity(Activity activity) { super.setActivity(activity); if (dialogMode) { activity.setTheme(android.R.style.Theme_Dialog); activity.requestWindowFeature(Window.FEATURE_NO_TITLE); } activity.getWindow().setSoftInputMode( WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); }
Example 4
Source File: UIHelper.java From coolreader with MIT License | 5 votes |
@SuppressLint("NewApi") public static void ToggleActionBar(Activity activity, boolean show) { if (!show) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar actionBar = activity.getActionBar(); if (actionBar != null) actionBar.hide(); } else { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); } } }
Example 5
Source File: Shake2Share.java From AndroidLinkup with GNU General Public License v2.0 | 5 votes |
public void setActivity(Activity activity) { super.setActivity(activity); int resId = getBitmapRes(activity, "ssdk_oks_shake_to_share_back"); if (resId > 0) { activity.setTheme(android.R.style.Theme_Dialog); activity.requestWindowFeature(Window.FEATURE_NO_TITLE); Window win = activity.getWindow(); win.setBackgroundDrawableResource(resId); } }
Example 6
Source File: HelpActivity.java From Noyze with Apache License 2.0 | 5 votes |
/** Makes an {@link Activity} a "popup" like a {@link Dialog}. */ public static void popup(final Activity mAct) { if (null == mAct) return; final Resources aRes = mAct.getResources(); if (null == aRes) return; DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) mAct.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); final int[] mWindowDims = new int[] { dm.widthPixels, dm.heightPixels }; final int mMaxWidth = aRes.getDimensionPixelSize(R.dimen.max_menu_width), mGutter = aRes.getDimensionPixelSize(R.dimen.activity_horizontal_margin); final boolean isBounded = (mWindowDims[0] > mMaxWidth); mAct.requestWindowFeature(Window.FEATURE_ACTION_BAR); mAct.requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); final Window mWindow = mAct.getWindow(); mWindow.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); // Now get our attributes and make the window dim it's background. final WindowManager.LayoutParams params = mWindow.getAttributes(); params.alpha = 1.0f; params.dimAmount = 0.5f; // Bound the height and barHeight for this overlay. if (isBounded) { params.width = mMaxWidth + (4 * mGutter); // Bound to the maximum of a square. if (mWindowDims[1] > params.width) { params.height = params.width; } else { params.height = (int) (0.81f * mWindowDims[1]); } } mWindow.setAttributes(params); }
Example 7
Source File: Shake2Share.java From ShareSDKShareDifMsgDemo-Android with MIT License | 5 votes |
public void setActivity(Activity activity) { super.setActivity(activity); int resId = getBitmapRes(activity, "ssdk_oks_shake_to_share_back"); if (resId > 0) { activity.setTheme(android.R.style.Theme_Dialog); activity.requestWindowFeature(Window.FEATURE_NO_TITLE); Window win = activity.getWindow(); win.setBackgroundDrawableResource(resId); } }
Example 8
Source File: Shake2Share.java From WeCenterMobile-Android with GNU General Public License v2.0 | 5 votes |
public void setActivity(Activity activity) { super.setActivity(activity); int resId = getBitmapRes(activity, "ssdk_oks_shake_to_share_back"); if (resId > 0) { activity.setTheme(android.R.style.Theme_Dialog); activity.requestWindowFeature(Window.FEATURE_NO_TITLE); Window win = activity.getWindow(); win.setBackgroundDrawableResource(resId); } }
Example 9
Source File: HelpActivity.java From Noyze with Apache License 2.0 | 5 votes |
/** Makes an {@link Activity} a "popup" like a {@link Dialog}. */ public static void popup(final Activity mAct) { if (null == mAct) return; final Resources aRes = mAct.getResources(); if (null == aRes) return; DisplayMetrics dm = new DisplayMetrics(); WindowManager wm = (WindowManager) mAct.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(dm); final int[] mWindowDims = new int[] { dm.widthPixels, dm.heightPixels }; final int mMaxWidth = aRes.getDimensionPixelSize(R.dimen.max_menu_width), mGutter = aRes.getDimensionPixelSize(R.dimen.activity_horizontal_margin); final boolean isBounded = (mWindowDims[0] > mMaxWidth); mAct.requestWindowFeature(Window.FEATURE_ACTION_BAR); mAct.requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); final Window mWindow = mAct.getWindow(); mWindow.setFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND, WindowManager.LayoutParams.FLAG_DIM_BEHIND); // Now get our attributes and make the window dim it's background. final WindowManager.LayoutParams params = mWindow.getAttributes(); params.alpha = 1.0f; params.dimAmount = 0.5f; // Bound the height and barHeight for this overlay. if (isBounded) { params.width = mMaxWidth + (4 * mGutter); // Bound to the maximum of a square. if (mWindowDims[1] > params.width) { params.height = params.width; } else { params.height = (int) (0.81f * mWindowDims[1]); } } mWindow.setAttributes(params); }
Example 10
Source File: Shake2Share.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
public void setActivity(Activity activity) { super.setActivity(activity); int resId = getBitmapRes(activity, "ssdk_oks_shake_to_share_back"); if (resId > 0) { activity.setTheme(android.R.style.Theme_Dialog); activity.requestWindowFeature(Window.FEATURE_NO_TITLE); Window win = activity.getWindow(); win.setBackgroundDrawableResource(resId); } }
Example 11
Source File: Shake2Share.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
public void setActivity(Activity activity) { super.setActivity(activity); int resId = getBitmapRes(activity, "ssdk_oks_shake_to_share_back"); if (resId > 0) { activity.setTheme(android.R.style.Theme_Dialog); activity.requestWindowFeature(Window.FEATURE_NO_TITLE); Window win = activity.getWindow(); win.setBackgroundDrawableResource(resId); } }
Example 12
Source File: Shake2Share.java From Huochexing12306 with Apache License 2.0 | 5 votes |
public void setActivity(Activity activity) { super.setActivity(activity); int resId = getBitmapRes(activity, "ssdk_oks_shake_to_share_back"); if (resId > 0) { activity.setTheme(android.R.style.Theme_Dialog); activity.requestWindowFeature(Window.FEATURE_NO_TITLE); Window win = activity.getWindow(); win.setBackgroundDrawableResource(resId); } }
Example 13
Source File: CustomActivity.java From WhereYouGo with GNU General Public License v3.0 | 5 votes |
protected static void setScreenBasic(Activity activity) { try { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); } catch (Exception e) { // TODO Logger.e(TAG, "setFullScreen(" + activity + ")", e); } }
Example 14
Source File: ScreenUtils.java From zone-sdk with MIT License | 4 votes |
public static void requestFillWindow(Activity context){ context.requestWindowFeature(Window.FEATURE_NO_TITLE); context.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
Example 15
Source File: ScreenUtils.java From zone-sdk with MIT License | 4 votes |
public static void requestNoTitle(Activity context){ context.requestWindowFeature(Window.FEATURE_NO_TITLE); }
Example 16
Source File: Api8Adapter.java From mytracks with Apache License 2.0 | 4 votes |
@Override public void hideTitle(Activity activity) { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); }
Example 17
Source File: ScreenUtils.java From ClassSchedule with Apache License 2.0 | 2 votes |
/** * 隐藏状态栏 * <p>也就是设置全屏,一定要在setContentView之前调用,否则报错</p> * <p>此方法Activity可以继承AppCompatActivity</p> * <p>启动的时候状态栏会显示一下再隐藏,比如QQ的欢迎界面</p> * <p>在配置文件中Activity加属性android:theme="@android:style/Theme.NoTitleBar.Fullscreen"</p> * <p>如加了以上配置Activity不能继承AppCompatActivity,会报错</p> * * @param activity activity */ public static void hideStatusBar(Activity activity) { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }
Example 18
Source File: AppTools.java From RxEasyHttp with Apache License 2.0 | 2 votes |
/** * </br><b>title : </b> 隐藏系统标题栏 * </br><b>description :</b>隐藏Activity的系统默认标题栏 * * @param activity Activity对象 */ public static void hideTitleBar(Activity activity) { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); }
Example 19
Source File: RxBarTool.java From RxTools-master with Apache License 2.0 | 2 votes |
/** * 隐藏Title * 一定要在setContentView之前调用,否则报错 * * @param activity */ public static void setNoTitle(Activity activity) { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); }
Example 20
Source File: BarUtils.java From Android-UtilCode with Apache License 2.0 | 2 votes |
/** * 隐藏状态栏 * <p>也就是设置全屏,一定要在setContentView之前调用,否则报错</p> * <p>此方法Activity可以继承AppCompatActivity</p> * <p>启动的时候状态栏会显示一下再隐藏,比如QQ的欢迎界面</p> * <p>在配置文件中Activity加属性android:theme="@android:style/Theme.NoTitleBar.Fullscreen"</p> * <p>如加了以上配置Activity不能继承AppCompatActivity,会报错</p> * * @param activity activity */ public static void hideStatusBar(Activity activity) { activity.requestWindowFeature(Window.FEATURE_NO_TITLE); activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); }