Java Code Examples for android.app.Activity#requestWindowFeature()

The following examples show how to use android.app.Activity#requestWindowFeature() . 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: coolreader   File: UIHelper.java    License: MIT License 6 votes vote down vote up
@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
protected static void setScreenBasic(Activity activity) {
    try {
        activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
    } catch (Exception e) {
        // TODO Logger.e(TAG, "setFullScreen(" + activity + ")", e);
    }
}
 
Example 3
Source Project: DevUtils   File: ScreenUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 设置屏幕为全屏无标题
 * <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 4
Source Project: Huochexing12306   File: Shake2Share.java    License: Apache License 2.0 5 votes vote down vote up
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 5
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
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 7
Source Project: Noyze   File: HelpActivity.java    License: Apache License 2.0 5 votes vote down vote up
/** 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 8
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
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 10
Source Project: Noyze   File: HelpActivity.java    License: Apache License 2.0 5 votes vote down vote up
/** 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 11
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 Project: coolreader   File: UIHelper.java    License: MIT License 5 votes vote down vote up
@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 13
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 14
Source Project: mytracks   File: Api8Adapter.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void hideTitle(Activity activity) {
  activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
}
 
Example 15
Source Project: zone-sdk   File: ScreenUtils.java    License: MIT License 4 votes vote down vote up
public static void  requestFillWindow(Activity context){
	context.requestWindowFeature(Window.FEATURE_NO_TITLE);
	context.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
 
Example 16
Source Project: zone-sdk   File: ScreenUtils.java    License: MIT License 4 votes vote down vote up
public static void  requestNoTitle(Activity context){
	context.requestWindowFeature(Window.FEATURE_NO_TITLE);
}
 
Example 17
Source Project: Android-UtilCode   File: BarUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 隐藏状态栏
 * <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 Project: RxTools-master   File: RxBarTool.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 隐藏Title
 * 一定要在setContentView之前调用,否则报错
 *
 * @param activity
 */
public static void setNoTitle(Activity activity) {
    activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
}
 
Example 19
Source Project: RxEasyHttp   File: AppTools.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * </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 20
Source Project: ClassSchedule   File: ScreenUtils.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 隐藏状态栏
 * <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);
}