本文整理汇总了Java中android.view.Window.getAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java Window.getAttributes方法的具体用法?Java Window.getAttributes怎么用?Java Window.getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.Window
的用法示例。
在下文中一共展示了Window.getAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: slideToChangeBrightness
import android.view.Window; //导入方法依赖的package包/类
protected void slideToChangeBrightness(float deltaY) {
mCenterView.setVisibility(VISIBLE);
hide();
mCenterView.setProVisibility(View.VISIBLE);
Window window = WindowUtil.scanForActivity(getContext()).getWindow();
WindowManager.LayoutParams attributes = window.getAttributes();
mCenterView.setIcon(R.drawable.ic_action_brightness);
int height = getMeasuredHeight();
if (mBrightness == -1.0f) mBrightness = 0.5f;
float brightness = deltaY * 2 / height * 1.0f + mBrightness;
if (brightness < 0) {
brightness = 0f;
}
if (brightness > 1.0f) brightness = 1.0f;
int percent = (int) (brightness * 100);
mCenterView.setTextView(percent + "%");
mCenterView.setProPercent(percent);
attributes.screenBrightness = brightness;
window.setAttributes(attributes);
}
示例2: onCreate
import android.view.Window; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
View view = getLayoutInflater().inflate(R.layout.view_dialog_select, null);
setContentView(view, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
Window window = getWindow();
// 设置显示动画
if (window != null) {
window.setWindowAnimations(R.style.main_menu_animStyle);
WindowManager.LayoutParams wl = window.getAttributes();
wl.x = 0;
wl.y = mActivity.getWindowManager().getDefaultDisplay().getHeight();
// 以下这两句是为了保证按钮可以水平满屏
wl.width = LayoutParams.MATCH_PARENT;
wl.height = LayoutParams.WRAP_CONTENT;
// 设置显示位置
onWindowAttributesChanged(wl);
}
initViews();
}
示例3: showRecordDialog
import android.view.Window; //导入方法依赖的package包/类
private void showRecordDialog(MediaProjection mediaProjection, String filePath, boolean isRecordAudio) {
if (mRecordDialog == null) {
mRecordDialog = new RecordScreenDialog(getContext(), R.style.record_dialog);
mRecordDialog.setFilePath(filePath);
Window window = mRecordDialog.getWindow();
window.setGravity(Gravity.BOTTOM);
WindowManager.LayoutParams layoutParams = window.getAttributes();
layoutParams.height = WindowManager.LayoutParams.WRAP_CONTENT;
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(layoutParams);
mRecordDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
// showSystemUI();
}
});
}
//第二个参数表述是否录制音频数据
mRecordDialog.setActivityResult(mediaProjection, isRecordAudio);
mRecordDialog.setIShareLivePlayer(mIShareLivePlayer);
mRecordDialog.setCallback(mCallback);
mRecordDialog.show();
}
示例4: onStart
import android.view.Window; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
if (getDialog()==null){
this.dismiss();
return;
}
Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.dimAmount = getDimAmount();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
if (getHeight() > 0) {
params.height = getHeight();
} else {
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
}
params.gravity = Gravity.BOTTOM;
window.setAttributes(params);
}
示例5: setWindowFlag
import android.view.Window; //导入方法依赖的package包/类
private static void setWindowFlag(Activity activity, final int bits, boolean on) {
Window win = activity.getWindow();
WindowManager.LayoutParams winParams = win.getAttributes();
if (on) {
winParams.flags |= bits;
} else {
winParams.flags &= ~bits;
}
win.setAttributes(winParams);
}
示例6: initDialogWidth
import android.view.Window; //导入方法依赖的package包/类
private void initDialogWidth() {
Window window = getWindow();
if (window == null) {
return;
}
WindowManager.LayoutParams wmlp = window.getAttributes();
wmlp.width = ViewGroup.LayoutParams.MATCH_PARENT;
window.setAttributes(wmlp);
}
示例7: show
import android.view.Window; //导入方法依赖的package包/类
@Override
public void show() {
Window dialogWindow = getWindow();
LayoutParams lp = dialogWindow.getAttributes();
dialogWindow.setGravity(Gravity.LEFT | Gravity.BOTTOM);
WindowManager m = context.getWindowManager();
Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
lp.width = d.getWidth();
lp.x = 0;
lp.y = 0;
dialogWindow.setAttributes(lp);
super.show();
}
示例8: show
import android.view.Window; //导入方法依赖的package包/类
@Override
public void show() {
Window dialogWindow = getWindow();
LayoutParams lp = dialogWindow.getAttributes();
lp.width = LayoutParams.MATCH_PARENT;
lp.height = LayoutParams.MATCH_PARENT;
/*WindowManager m = context.getWindowManager();
Display d = m.getDefaultDisplay(); // 获取屏幕宽、高用
lp.width = d.getWidth();*/
dialogWindow.setAttributes(lp);
EventBus.getDefault().register(this);
super.show();
}
示例9: initWindowParams
import android.view.Window; //导入方法依赖的package包/类
private void initWindowParams() {
Window dialogWindow = getWindow();
// 获取屏幕宽、高用
WindowManager wm = (WindowManager) mContext
.getSystemService(Context.WINDOW_SERVICE);
Display display = wm.getDefaultDisplay();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
lp.width = (int) (display.getWidth() * 0.65); // 宽度设置为屏幕的0.65
dialogWindow.setGravity(Gravity.CENTER);
dialogWindow.setAttributes(lp);
}
示例10: FlymeSetStatusBarLightMode
import android.view.Window; //导入方法依赖的package包/类
/**
* 设置状态栏图标为深色和魅族特定的文字风格
* 可以用来判断是否为Flyme用户
* @param window 需要设置的窗口
* @param dark 是否把状态栏字体及图标颜色设置为深色
* @return boolean 成功执行返回true
*
*/
public static boolean FlymeSetStatusBarLightMode(Window window, boolean dark) {
boolean result = 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) {
}
}
return result;
}
示例11: onStart
import android.view.Window; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
if (mIsTransparent) {
Window window = getDialog().getWindow();
WindowManager.LayoutParams windowParams = window.getAttributes();
windowParams.dimAmount = 0.0f;
window.setAttributes(windowParams);
}
}
示例12: setWindowParams
import android.view.Window; //导入方法依赖的package包/类
public void setWindowParams(int width) {
Window window = getWindow();
LayoutParams params = window.getAttributes();
if (width <= 0) {
width = -1;
}
params.width = width;
params.height = -1;
params.gravity = 80;
window.setAttributes(params);
}
示例13: 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);
}
示例14: setMatchParent
import android.view.Window; //导入方法依赖的package包/类
public BaseDialog setMatchParent() {
Window dialogWindow = getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
dialogWindow.setAttributes(lp);
return this;
}
示例15: updateLayoutHeightOf
import android.view.Window; //导入方法依赖的package包/类
public static void updateLayoutHeightOf(final Window window, final int layoutHeight) {
final WindowManager.LayoutParams params = window.getAttributes();
if (params != null && params.height != layoutHeight) {
params.height = layoutHeight;
window.setAttributes(params);
}
}