List of usage examples for android.view Window setAttributes
public void setAttributes(WindowManager.LayoutParams a)
From source file:com.example.deii.trustone.SignUpActivity.java
private void showPicSelectDialog(final Context ctx) { dialog = new Dialog(ctx, R.style.DialogSlideAnim1); dialog.setContentView(R.layout.dialog_select_image); dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent); Window window = dialog.getWindow(); WindowManager.LayoutParams wlp = window.getAttributes(); wlp.gravity = Gravity.BOTTOM;/*from ww w .j av a 2 s . c om*/ wlp.flags &= ~WindowManager.LayoutParams.FLAG_DIM_BEHIND; window.setAttributes(wlp); TextView chooseFromGallery = (TextView) dialog.findViewById(R.id.text_fromGallery); chooseFromGallery.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { loadPermissions(Manifest.permission.READ_EXTERNAL_STORAGE, GALLERY_REQUEST); } else startGallery(); } }); TextView takeFromCamera = (TextView) dialog.findViewById(R.id.text_fromCamera); takeFromCamera.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) loadPermissions(Manifest.permission.CAMERA, CAMERA_REQUEST); else startCamera(); } }); TextView imgCancel = (TextView) dialog.findViewById(R.id.text_dialogClose); imgCancel.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
From source file:com.ovrhere.android.careerstack.ui.fragments.dialogs.SearchBarDialogFragment.java
/** Initializes the dialogs animations and dim. */ private void initAnimationAndDim() { Window win = getDialog().getWindow(); win.setGravity(Gravity.TOP);/*from ww w.ja va 2 s .c o m*/ win.setWindowAnimations(R.style.SearchBarAnimation); WindowManager.LayoutParams lp = win.getAttributes(); lp.dimAmount = 0.3f; //TODO abstract? is it necessary? win.setAttributes(lp); win.addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); }
From source file:com.xxxifan.devbox.core.util.ViewUtils.java
/** * set status bar icon to light theme, which is called dark mode. * should be called in onCreate()// w ww . ja v a 2 s .c o m */ public static void setStatusBarLightMode(Activity activity, boolean lightMode) { if (activity == null || activity.getWindow() == null) { return; } Window window = activity.getWindow(); boolean changed = false; // try miui try { Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams"); Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE"); int darkIcon = field.getInt(layoutParams); Method extraFlagField = window.getClass().getMethod("setExtraFlags", int.class, int.class); extraFlagField.invoke(window, lightMode ? darkIcon : 0, darkIcon); changed = true; } catch (Exception ignored) { } // try flyme try { WindowManager.LayoutParams lp = window.getAttributes(); Field darkIcon = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON"); Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags"); darkIcon.setAccessible(true); meizuFlags.setAccessible(true); int bit = darkIcon.getInt(null); int value = meizuFlags.getInt(lp); if (lightMode) { value |= bit; } else { value &= ~bit; } meizuFlags.setInt(lp, value); window.setAttributes(lp); changed = true; } catch (Exception ignored) { } if (!changed && Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { int visibility = window.getDecorView().getSystemUiVisibility(); if (lightMode) { visibility |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } else { visibility &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } window.getDecorView().setSystemUiVisibility(visibility); } }
From source file:de.vanita5.twittnuker.activity.support.QuickSearchBarActivity.java
private void updateWindowAttributes() { final Window window = getWindow(); final WindowManager.LayoutParams attributes = window.getAttributes(); attributes.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; window.setAttributes(attributes); }
From source file:cn.robertzhang.libraries.base.BaseFragmentActivity.java
/** * set status bar translucency/*from w ww . ja va 2 s .c o m*/ * * @param on */ protected void setTranslucentStatus(boolean on) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { 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); } }
From source file:org.getlantern.firetweet.activity.support.QuickSearchBarActivity.java
private void updateWindowAttributes() { final Window window = getWindow(); final WindowManager.LayoutParams attributes = window.getAttributes(); attributes.gravity = Gravity.TOP | Gravity.CENTER_HORIZONTAL; attributes.y = mSystemWindowsInsets.top; window.setAttributes(attributes); }
From source file:com.cloverstudio.spika.CreateGroupActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case GET_IMAGE_DIALOG: mGetImageDialog = new Dialog(CreateGroupActivity.this, R.style.TransparentDialogTheme); mGetImageDialog.getWindow().setGravity(Gravity.BOTTOM); mGetImageDialog.setContentView(R.layout.dialog_get_image); // Grab the window of the dialog, and change the width WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); Window window = mGetImageDialog.getWindow(); lp.copyFrom(window.getAttributes()); // This makes the dialog take up the full width lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(lp);/* w ww .j a v a2s . com*/ final Button btnGallery = (Button) mGetImageDialog.findViewById(R.id.btnGallery); btnGallery.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); btnGallery.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent galleryIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class); galleryIntent.putExtra("type", "gallery"); galleryIntent.putExtra("createGroup", true); CreateGroupActivity.this.startActivity(galleryIntent); mGetImageDialog.dismiss(); } }); final Button btnCamera = (Button) mGetImageDialog.findViewById(R.id.btnCamera); btnCamera.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); btnCamera.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent cameraIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class); cameraIntent.putExtra("type", "camera"); cameraIntent.putExtra("createGroup", true); CreateGroupActivity.this.startActivity(cameraIntent); mGetImageDialog.dismiss(); } }); final Button btnRemovePhoto = (Button) mGetImageDialog.findViewById(R.id.btnRemovePhoto); btnRemovePhoto.setTypeface(SpikaApp.getTfMyriadProBold(), Typeface.BOLD); btnRemovePhoto.setOnClickListener(new OnClickListener() { public void onClick(View v) { mGroupAvatarId = ""; gGroupImage = null; Utils.displayImage(mGroupAvatarId, mIvGroupImage, ImageLoader.LARGE, R.drawable.group_stub_large, false); mGetImageDialog.dismiss(); } }); return mGetImageDialog; default: return null; } }
From source file:info.hl.mediam.CreateGroupActivity.java
@Override protected Dialog onCreateDialog(int id) { switch (id) { case GET_IMAGE_DIALOG: mGetImageDialog = new Dialog(CreateGroupActivity.this, R.style.TransparentDialogTheme); mGetImageDialog.getWindow().setGravity(Gravity.BOTTOM); mGetImageDialog.setContentView(R.layout.dialog_get_image); // Grab the window of the dialog, and change the width WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); Window window = mGetImageDialog.getWindow(); lp.copyFrom(window.getAttributes()); // This makes the dialog take up the full width lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(lp); final Button btnGallery = (Button) mGetImageDialog.findViewById(R.id.btnGallery); btnGallery.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD); btnGallery.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent galleryIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class); galleryIntent.putExtra("type", "gallery"); galleryIntent.putExtra("createGroup", true); CreateGroupActivity.this.startActivity(galleryIntent); mGetImageDialog.dismiss(); }/*w w w . j a v a 2 s.co m*/ }); final Button btnCamera = (Button) mGetImageDialog.findViewById(R.id.btnCamera); btnCamera.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD); btnCamera.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent cameraIntent = new Intent(CreateGroupActivity.this, CameraCropActivity.class); cameraIntent.putExtra("type", "camera"); cameraIntent.putExtra("createGroup", true); CreateGroupActivity.this.startActivity(cameraIntent); mGetImageDialog.dismiss(); } }); final Button btnRemovePhoto = (Button) mGetImageDialog.findViewById(R.id.btnRemovePhoto); btnRemovePhoto.setTypeface(MediamApp.getTfMyriadProBold(), Typeface.BOLD); btnRemovePhoto.setOnClickListener(new OnClickListener() { public void onClick(View v) { mGroupAvatarId = ""; gGroupImage = null; Utils.displayImage(mGroupAvatarId, mIvGroupImage, ImageLoader.LARGE, R.drawable.group_stub_large, false); mGetImageDialog.dismiss(); } }); return mGetImageDialog; default: return null; } }
From source file:co.codecrunch.musicplayerlite.activities.MusicPlayerBaseActivity.java
private void setTranslucentStatus(boolean on) { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) {//from w ww .j av a2s . c o m winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }
From source file:com.example.caique.educam.Activities.TimelineActivity.java
@TargetApi(19) private void setTranslucentStatus(boolean on) { Window win = getWindow(); WindowManager.LayoutParams winParams = win.getAttributes(); win.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION, WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION); /* win.setFlags(/*w w w. j a va 2 s . c om*/ WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS); */ final int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS; if (on) { winParams.flags |= bits; } else { winParams.flags &= ~bits; } win.setAttributes(winParams); }