本文整理汇总了Java中android.view.Window.setAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java Window.setAttributes方法的具体用法?Java Window.setAttributes怎么用?Java Window.setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.Window
的用法示例。
在下文中一共展示了Window.setAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initView
import android.view.Window; //导入方法依赖的package包/类
private void initView() {
Window window = getWindow();
window.setGravity(Gravity.CENTER); // 此处可以设置dialog显示的位置为居中
window.setWindowAnimations(R.style.bottom_menu_animation); // 添加动画效果
View child = getLayoutInflater().inflate(R.layout.layout_dialog_base, null, false);
setContentView(child);
mContainer = (FrameLayout) findViewById(R.id.fl_container);
mBtnPanel = (FrameLayout) findViewById(R.id.fl_btn_panel);
closeIV = (ImageView) findViewById(R.id.iv_close);
closeIV.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dismiss();
}
});
Window dialogWindow = getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
DisplayMetrics d = mContext.getResources().getDisplayMetrics(); // 获取屏幕宽、高用
lp.width = (int) (d.widthPixels * 0.8); // 宽度设置为屏幕的0.9
dialogWindow.setAttributes(lp);
setIsCancelable(true);
setOnDismissListener(this);
}
示例2: setAutobrightness
import android.view.Window; //导入方法依赖的package包/类
protected void setAutobrightness(Activity activity, ContentResolver resolver, boolean on) {
super.setAutobrightness(activity, resolver, on);
// set auto brightness on/off
int value = on ? 255 : 128; // auto or middle brightness
Settings.System.putInt(resolver, Settings.System.SCREEN_BRIGHTNESS, value);
if (!on) {
// update slider
RangeSetting setting = (RangeSetting) mSetting;
setting.value = getPercentValue(value);
setting.descr = null;
setting.enabled = false;
setting.checked = false;
setting.updateView();
}
// update current view's brightness
LayoutParams attrs = mActivity.getWindow().getAttributes();
attrs.screenBrightness = on ? 1f : value / (float) getMaximum();
// request brightness update
Window window = mActivity.getWindow();
window.setAttributes(attrs);
}
示例3: CustomDialog
import android.view.Window; //导入方法依赖的package包/类
public CustomDialog(Context context) {
super(context, R.style.DialogTheme);
// 设置内容
setContentView(R.layout.dialog_layout);
setCanceledOnTouchOutside(true);//设置点击dialog外面都可以取消dialog
setCancelable(true);//设置点击返回键能取消
// 设置窗口属性
Window window = getWindow();
WindowManager.LayoutParams params = window.getAttributes();
// 设置宽度、高度、密度、对齐方式
float density = getDensity(context);
params.width = (int) (80 * density);
params.height = (int) (80 * density);
params.gravity = Gravity.CENTER;
window.setAttributes(params);
}
示例4: createDialogWithView
import android.view.Window; //导入方法依赖的package包/类
public Dialog createDialogWithView(View localView) {
Dialog dialog = new Dialog(getContext(), R.style.jz_style_dialog_progress);
dialog.setContentView(localView);
Window window = dialog.getWindow();
window.addFlags(Window.FEATURE_ACTION_BAR);
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
window.addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
window.setLayout(-2, -2);
WindowManager.LayoutParams localLayoutParams = window.getAttributes();
localLayoutParams.gravity = Gravity.CENTER;
window.setAttributes(localLayoutParams);
return dialog;
}
示例5: onCreateView
import android.view.Window; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
//设置无标题
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
//设置从底部弹出
Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL;
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setAttributes(params);
return null;
}
示例6: setMeiZuDarkMode
import android.view.Window; //导入方法依赖的package包/类
/**
* 设置魅族手机状态栏图标颜色风格
* 可以用来判断是否为Flyme用户
*
* @param window 需要设置的窗口
* @param dark 是否把状态栏字体及图标颜色设置为深色
* @return boolean 成功执行返回true
*/
public static boolean setMeiZuDarkMode(Window window, boolean dark) {
boolean result = false;
if (Build.VERSION.SDK_INT >= 24) {
return false;
}
if (window != null) {
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);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
}
return result;
}
示例7: show
import android.view.Window; //导入方法依赖的package包/类
@Override public void show() {
super.show();
Window dialogWindow = getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
dialogWindow.setGravity(Gravity.CENTER);
dialogWindow.setAttributes(lp);
}
示例8: CustomDialog
import android.view.Window; //导入方法依赖的package包/类
public CustomDialog(Context context,int width,int height,int layout,int style,int gravity,int anim){
super(context,style);
//设置属性
setContentView(layout);
Window window = getWindow();
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.gravity = gravity;
window.setAttributes(layoutParams);
window.setWindowAnimations(anim);
}
示例9: initFullScreen
import android.view.Window; //导入方法依赖的package包/类
private void initFullScreen(Dialog dialog) {
Window window = dialog.getWindow();
if (window != null) {
ViewGroup.LayoutParams params = window.getAttributes();
params.width = ViewGroup.LayoutParams.MATCH_PARENT;
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
window.setAttributes((android.view.WindowManager.LayoutParams) params);
}
}
示例10: removeVisibilityFlag
import android.view.Window; //导入方法依赖的package包/类
/**
* Convenience method to remove a visibility flag from the window, leaving other flags that are
* not specified intact.
*/
public static void removeVisibilityFlag(final Window window, final int flag) {
if (VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB) {
WindowManager.LayoutParams attrs = window.getAttributes();
attrs.systemUiVisibility &= ~flag;
window.setAttributes(attrs);
}
}
示例11: setBlurEffect
import android.view.Window; //导入方法依赖的package包/类
protected void setBlurEffect() {
final Window window = getWindow();
final WindowManager.LayoutParams lp = window.getAttributes();
// lp.alpha=0.8f;
lp.dimAmount = 0.6f;
window.setAttributes(lp);
window.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
// window.addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
}
示例12: setFullscreen
import android.view.Window; //导入方法依赖的package包/类
/**
* turns on fullscreen mode in the app
*
* @param enabled
* whether to enable fullscreen or not
*/
public void setFullscreen(boolean enabled) {
Window win = getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
final int bits = WindowManager.LayoutParams.FLAG_FULLSCREEN;
if (enabled) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
if (mCustomView != null) {
mCustomView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
} else {
mBrowserFrame.setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
}
win.setAttributes(winParams);
if(mToolbarLayout!=null){
mToolbarLayout.setVisibility(View.GONE);
}
if(shortcutToolbar!=null){
shortcutToolbar.setVisibility(View.GONE);
}
if(fullscreenCancelBtn!=null){
fullscreenCancelBtn.setVisibility(View.VISIBLE);
}
}
示例13: CustomLoadingDialog
import android.view.Window; //导入方法依赖的package包/类
public CustomLoadingDialog(Context context, int width, int height, int layout, int style) {
super(context, style);
setContentView(layout);
this.textView = (TextView) findViewById(2131363110);
Window window = getWindow();
LayoutParams params = window.getAttributes();
params.width = UIsUtils.zoomWidth(width);
params.height = UIsUtils.zoomWidth(height);
params.gravity = 17;
window.setAttributes(params);
}
示例14: show
import android.view.Window; //导入方法依赖的package包/类
@Override
public void show() {
Window dialogWindow = getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
dialogWindow.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
WindowManager m = mContext.getWindowManager();
Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
lp.width = (int) (d.getWidth() * 0.8);
lp.y = 80; // 新位置Y坐标
dialogWindow.setAttributes(lp);
super.show();
if (mDialogListener != null) {
mDialogListener.onDialogShow();
}
}
示例15: setTranslucentStatus
import android.view.Window; //导入方法依赖的package包/类
@TargetApi(19)
private 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);
}