android.view.WindowManager.LayoutParams Java Examples
The following examples show how to use
android.view.WindowManager.LayoutParams.
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: JUIHelper.java From connectivity-samples with Apache License 2.0 | 6 votes |
public void addView(final View view) { activity_.runOnUiThread(new Runnable() { @Override public void run() { if (JUIRelativeLayout_ != null) { JUIRelativeLayout_.addView(view); ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) view .getLayoutParams(); if (params instanceof RelativeLayout.LayoutParams == false) { // Switching to relative layout param RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams( params.width, params.height); layoutParams.leftMargin = params.leftMargin; layoutParams.bottomMargin = params.bottomMargin; layoutParams.rightMargin = params.rightMargin; layoutParams.topMargin = params.topMargin; view.setLayoutParams(layoutParams); } } } }); return; }
Example #2
Source File: PopupWindow.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Wraps a content view in a PopupViewContainer. * * @param contentView the content view to wrap * @return a PopupViewContainer that wraps the content view */ private PopupBackgroundView createBackgroundView(View contentView) { final ViewGroup.LayoutParams layoutParams = mContentView.getLayoutParams(); final int height; if (layoutParams != null && layoutParams.height == WRAP_CONTENT) { height = WRAP_CONTENT; } else { height = MATCH_PARENT; } final PopupBackgroundView backgroundView = new PopupBackgroundView(mContext); final PopupBackgroundView.LayoutParams listParams = new PopupBackgroundView.LayoutParams( MATCH_PARENT, height); backgroundView.addView(contentView, listParams); return backgroundView; }
Example #3
Source File: Util.java From Float-Bar with Eclipse Public License 1.0 | 6 votes |
/** * 对windowManager进行设置 * * @param wmParams * @return */ public static WindowManager.LayoutParams getParams(WindowManager.LayoutParams wmParams) { wmParams = new WindowManager.LayoutParams(); // 设置window type 下面变量2002是在屏幕区域显示,2003则可以显示在状态栏之上 // wmParams.type = LayoutParams.TYPE_PHONE; // wmParams.type = LayoutParams.TYPE_SYSTEM_ALERT; wmParams.type = LayoutParams.TYPE_SYSTEM_ERROR; // 设置图片格式,效果为背景透明 wmParams.format = PixelFormat.RGBA_8888; // 设置浮动窗口不可聚焦(实现操作除浮动窗口外的其他可见窗口的操作) // wmParams.flags = LayoutParams.FLAG_NOT_FOCUSABLE; // 设置可以显示在状态栏上 wmParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; // 设置悬浮窗口长宽数据 wmParams.width = WindowManager.LayoutParams.WRAP_CONTENT; wmParams.height = WindowManager.LayoutParams.WRAP_CONTENT; return wmParams; }
Example #4
Source File: PopupWindow.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * <p>Invoke the popup window by adding the content view to the window * manager.</p> * * <p>The content view must be non-null when this method is invoked.</p> * * @param p the layout parameters of the popup's content view */ private void invokePopup(WindowManager.LayoutParams p) { if (mContext != null) { p.packageName = mContext.getPackageName(); } final PopupDecorView decorView = mDecorView; decorView.setFitsSystemWindows(mLayoutInsetDecor); setLayoutDirectionFromAnchor(); mWindowManager.addView(decorView, p); if (mEnterTransition != null) { decorView.requestEnterTransition(mEnterTransition); } }
Example #5
Source File: YearMonthDayHourMinuteActivity.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
@Override protected void onStart() { WindowManager m = getWindowManager(); Display d = m.getDefaultDisplay(); // 为获取屏幕宽、高 //System.out.println("d.getHeight():" + d.getHeight()); LayoutParams p = getWindow().getAttributes(); // 获取对话框当前的参数值 p.height = (int) (d.getHeight() * 1.0); // 高度设置为屏幕的1.0 p.width = (int) (d.getWidth() * 1.0); // 宽度设置为屏幕的0.8 p.alpha = 1.0f; // 设置本身透明度 p.dimAmount = 0.0f; // 设置黑暗度 getWindow().setAttributes(p); // 设置生效 getWindow().setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); // 设置靠右对齐 super.onStart(); }
Example #6
Source File: UBrightnessHelper.java From UCDMediaPlayer_Android with MIT License | 6 votes |
@Override public void setValue(int level, boolean isTouch) { if (isZero() && isTouch) { level = historyLevel; } if (level < 0) { level = 0; } else if (level > maxLevel) { level = maxLevel; } float tempValue = level; if (context != null && context instanceof Activity) { LayoutParams lp = ((Activity) (context)).getWindow().getAttributes(); lp.screenBrightness = tempValue / maxLevel; ((Activity) (context)).getWindow().setAttributes(lp); updateValue(); if (!isZero()) { historyLevel = currentLevel; } if (changeListener != null) { changeListener.onUpdateUI(); } } }
Example #7
Source File: PolicyControl.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
public static int getSystemUiVisibility(WindowState win, LayoutParams attrs) { attrs = attrs != null ? attrs : win.getAttrs(); int vis = win != null ? win.getSystemUiVisibility() : (attrs.systemUiVisibility | attrs.subtreeSystemUiVisibility); if (sImmersiveStatusFilter != null && sImmersiveStatusFilter.matches(attrs)) { vis |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; vis &= ~(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.STATUS_BAR_TRANSLUCENT); } if (sImmersiveNavigationFilter != null && sImmersiveNavigationFilter.matches(attrs)) { vis |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION; vis &= ~(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.NAVIGATION_BAR_TRANSLUCENT); } return vis; }
Example #8
Source File: CredentialRetrieveActivity.java From OpenYOLO-Android with Apache License 2.0 | 6 votes |
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(LayoutParams.FLAG_NOT_TOUCHABLE); CredentialRetrieveRequest request = getIntent().getParcelableExtra(EXTRA_REQUEST); if (null == request) { setResult( CredentialRetrieveResult.CODE_UNKNOWN, CredentialRetrieveResult.UNKNOWN.toResultDataIntent()); finish(); return; } BroadcastQueryClient.getInstance(this) .queryFor( CREDENTIAL_DATA_TYPE, request.toProtocolBuffer(), RETRIEVE_TIMEOUT_MS, new CredentialRetrieveQueryCallback(request)); }
Example #9
Source File: PopupDialog.java From Noyze with Apache License 2.0 | 6 votes |
private static WindowManager.LayoutParams getWindowLayoutParams() { int flags = (LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | LayoutParams.FLAG_DIM_BEHIND ); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) flags |= LayoutParams.FLAG_HARDWARE_ACCELERATED; if (!BuildConfig.DEBUG) flags |= LayoutParams.FLAG_SECURE; LayoutParams WPARAMS = new WindowManager.LayoutParams( LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, LayoutParams.TYPE_SYSTEM_ALERT, flags, PixelFormat.TRANSLUCENT); final int windowAnimations = getInternalStyle("Animation_Dialog"); if (windowAnimations > 0) WPARAMS.windowAnimations = windowAnimations; WPARAMS.dimAmount = 0.6f; WPARAMS.packageName = PopupDialog.class.getPackage().getName(); WPARAMS.setTitle(TAG); WPARAMS.gravity = Gravity.CENTER; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) WPARAMS.screenBrightness = WPARAMS.buttonBrightness = LayoutParams.BRIGHTNESS_OVERRIDE_NONE; return WPARAMS; }
Example #10
Source File: TaskGuide.java From letv with Apache License 2.0 | 6 votes |
private void a() { this.b = new TextView(this.a.F); this.b.setTextColor(Color.rgb(255, 255, 255)); this.b.setTextSize(15.0f); this.b.setShadowLayer(1.0f, 1.0f, 1.0f, Color.rgb(242, 211, 199)); this.b.setGravity(3); this.b.setEllipsize(TruncateAt.END); this.b.setIncludeFontPadding(false); this.b.setSingleLine(true); ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, -2); layoutParams.weight = 1.0f; layoutParams.leftMargin = this.a.a(4); addView(this.b, layoutParams); this.c = new Button(this.a.F); this.c.setPadding(0, 0, 0, 0); this.c.setTextSize(16.0f); this.c.setTextColor(Color.rgb(255, 255, 255)); this.c.setShadowLayer(1.0f, 1.0f, 1.0f, Color.rgb(242, 211, 199)); this.c.setIncludeFontPadding(false); this.c.setOnClickListener(new f(this.a, this.d.a)); layoutParams = new LinearLayout.LayoutParams(this.a.a(TaskGuide.p), this.a.a(TaskGuide.q)); layoutParams.leftMargin = this.a.a(2); layoutParams.rightMargin = this.a.a(8); addView(this.c, layoutParams); }
Example #11
Source File: DemoActivity_1.java From android-art-res with Apache License 2.0 | 5 votes |
private void initView() { Dialog dialog = new Dialog(this.getApplicationContext()); TextView textView = new TextView(this); textView.setText("this is toast!"); dialog.setContentView(textView); dialog.getWindow().setType(LayoutParams.TYPE_SYSTEM_ERROR); dialog.show(); }
Example #12
Source File: TaskGuide.java From letv with Apache License 2.0 | 5 votes |
private void a(boolean z) { this.I = SystemClock.currentThreadTimeMillis(); if (z) { this.G = true; } else { this.H = true; } this.J = this.d.height; this.K = this.d.y; LayoutParams layoutParams = this.d; layoutParams.flags |= 16; this.f.updateViewLayout(this.e, this.d); }
Example #13
Source File: RxDialog.java From RxTools-master with Apache License 2.0 | 5 votes |
/** * 设置宽度match_parent */ public void setFullScreenWidth() { Window window = getWindow(); window.getDecorView().setPadding(0, 0, 0, 0); WindowManager.LayoutParams lp = window.getAttributes(); lp.width = WindowManager.LayoutParams.FILL_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; window.setAttributes(lp); }
Example #14
Source File: CustomLoadingDialog.java From letv with Apache License 2.0 | 5 votes |
public void setWindowParams(int width, int height, int gravity) { int i = -1; Window window = getWindow(); LayoutParams params = window.getAttributes(); if (width <= 0) { width = -1; } params.width = width; if (height > 0) { i = height; } params.height = i; params.gravity = gravity; window.setAttributes(params); }
Example #15
Source File: AlarmFrDialog.java From AssistantBySDK with Apache License 2.0 | 5 votes |
@Override public boolean dispatchTouchEvent(MotionEvent ev) { if (context.getWindow().getAttributes().screenBrightness == 0.01f) { LayoutParams params = context.getWindow().getAttributes(); params.screenBrightness = LayoutParams.BRIGHTNESS_OVERRIDE_NONE; context.getWindow().setAttributes(params); } return super.dispatchTouchEvent(ev); }
Example #16
Source File: LockLayer.java From BigApp_Discuz_Android with Apache License 2.0 | 5 votes |
private void init() { isLocked = false; mWindowManager = mActivty.getWindowManager(); mLockViewLayoutParams = new LayoutParams(); mLockViewLayoutParams.width = LayoutParams.MATCH_PARENT; mLockViewLayoutParams.height = LayoutParams.MATCH_PARENT; // 实现关键 mLockViewLayoutParams.type = LayoutParams.TYPE_SYSTEM_ERROR; // apktool value,这个值具体是哪个变量还请网友帮忙 mLockViewLayoutParams.flags = 1280; }
Example #17
Source File: EmojiconsPopup.java From AndroidKeyboard with GNU General Public License v3.0 | 5 votes |
/** * Constructor * @param rootView The top most layout in your view hierarchy. The difference of this view and the screen height will be used to calculate the keyboard height. * @param mContext The context of current activity. */ public EmojiconsPopup(View rootView, Context mContext){ super(mContext); this.mContext = mContext; this.rootView = rootView; View customView = createCustomView(); setContentView(customView); setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE); //default size setSize((int) mContext.getResources().getDimension(R.dimen.keyboard_height), LayoutParams.MATCH_PARENT); }
Example #18
Source File: ModifyUuidFragment.java From Android-nRF-Beacon with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); // Show soft keyboard automatically getDialog().getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE); mUuidView.setOnEditorActionListener(this); }
Example #19
Source File: RLDialog.java From Roid-Library with Apache License 2.0 | 5 votes |
/** * */ public void createView() { super.setContentView(getView()); window = getWindow(); layoutParams = window.getAttributes(); super.setCanceledOnTouchOutside(true); window.addFlags(LayoutParams.FLAG_DIM_BEHIND); layoutParams.alpha = 0.98765f; layoutParams.dimAmount = 0.4321f; window.setWindowAnimations(R.style.ANIMATIONS_SCALE_FADE); }
Example #20
Source File: EasyAlertDialog.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public EasyAlertDialog(Context context, int resourceId, int style) { super(context, style); this.context = context; if (-1 != resourceId) { setContentView(resourceId); this.resourceId = resourceId; } WindowManager.LayoutParams Params = getWindow().getAttributes(); Params.width = LayoutParams.MATCH_PARENT; Params.height = LayoutParams.MATCH_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) Params); }
Example #21
Source File: BaseDialog.java From SprintNBA with Apache License 2.0 | 5 votes |
/** set window dim or not(设置背景是否昏暗) */ public T dimEnabled(boolean isDimEnabled) { if (isDimEnabled) { getWindow().addFlags(LayoutParams.FLAG_DIM_BEHIND); } else { getWindow().clearFlags(LayoutParams.FLAG_DIM_BEHIND); } return (T) this; }
Example #22
Source File: CameraService.java From glass_snippets with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public int onStartCommand(Intent intent, int flags, int startId) { if (intent.getExtras() != null) { Bundle e = intent.getExtras(); Log.d(TAG, e.keySet().toString()); mWidth = e.getInt(Parameters.WIDTH, mWidth); Log.e(TAG, String.format("mWidth is %d", mWidth)); mHeight = e.getInt(Parameters.HEIGHT, mHeight); mX = e.getInt(Parameters.X, mX); mY = e.getInt(Parameters.Y, mY); mOutFile = e.getString(Parameters.OUTFILE, mOutFile); mCaptureRate = e.getFloat(Parameters.RATE, mCaptureRate); } // Create new SurfaceView, and put on top of all other windows windowManager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); surfaceView = new SurfaceView(this); LayoutParams layoutParams = new WindowManager.LayoutParams( mWidth, mHeight, mX, mY, WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY, WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH, PixelFormat.TRANSLUCENT ); layoutParams.gravity = Gravity.LEFT | Gravity.TOP; windowManager.addView(surfaceView, layoutParams); surfaceView.getHolder().addCallback(this); super.onStartCommand(intent, flags, startId); return START_NOT_STICKY; }
Example #23
Source File: SimpleOverlay.java From brailleback with Apache License 2.0 | 5 votes |
/** * Sets the current layout parameters and applies them immediately. * * @param params The layout parameters to use. */ public void setParams(LayoutParams params) { mParams.copyFrom(params); if (mVisible) { mWindowManager.updateViewLayout(mContentView, mParams); } }
Example #24
Source File: EmojiconsPopup.java From AndroidKeyboard with GNU General Public License v3.0 | 5 votes |
/** * Call this function to resize the emoji popup according to your soft keyboard size */ public void setSizeForSoftKeyboard(){ rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() { @Override public void onGlobalLayout() { Rect r = new Rect(); rootView.getWindowVisibleDisplayFrame(r); int screenHeight = getUsableScreenHeight(); int heightDifference = screenHeight - (r.bottom - r.top); int resourceId = mContext.getResources() .getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { heightDifference -= mContext.getResources() .getDimensionPixelSize(resourceId); } if (heightDifference > 100) { keyBoardHeight = heightDifference; setSize(LayoutParams.MATCH_PARENT, keyBoardHeight); if(isOpened == false){ if(onSoftKeyboardOpenCloseListener!=null) onSoftKeyboardOpenCloseListener.onKeyboardOpen(keyBoardHeight); } isOpened = true; if(pendingOpen){ showAtBottom(); pendingOpen = false; } } else{ isOpened = false; if(onSoftKeyboardOpenCloseListener!=null) onSoftKeyboardOpenCloseListener.onKeyboardClose(); } } }); }
Example #25
Source File: CustomLoadingDialog.java From letv with Apache License 2.0 | 5 votes |
public void setWindowParams(int width, int height, int gravity) { int i = -1; Window window = getWindow(); LayoutParams params = window.getAttributes(); if (width <= 0) { width = -1; } params.width = width; if (height > 0) { i = height; } params.height = i; params.gravity = gravity; window.setAttributes(params); }
Example #26
Source File: PopupWindow.java From Noyze with Apache License 2.0 | 5 votes |
/** * Move the PopupWindow by a delta x and y. Pass 0 to keep the * current position. <em>Note</em>: not all windows observe this behavior. */ public void move(final int dx, final int dy) { LayoutParams wParams = getWindowParams(); wParams.gravity = (Gravity.LEFT | Gravity.TOP); wParams.x += dx; wParams.y += dy; if (!mAllowOffScreen) bound(); onWindowAttributesChanged(); }
Example #27
Source File: CaculatorDialog.java From AssistantBySDK with Apache License 2.0 | 5 votes |
@Override public boolean dispatchTouchEvent(MotionEvent ev) { if (context.getWindow().getAttributes().screenBrightness == 0.01f) { LayoutParams params = context.getWindow().getAttributes(); params.screenBrightness = LayoutParams.BRIGHTNESS_OVERRIDE_NONE; context.getWindow().setAttributes(params); } return super.dispatchTouchEvent(ev); }
Example #28
Source File: CustomBaseDialog.java From letv with Apache License 2.0 | 5 votes |
public CustomBaseDialog(Context context, View view, int style, int gravity) { super(context, style); if (gravity == 80) { getWindow().setSoftInputMode(16); getWindow().getDecorView().setPadding(0, 0, 0, 0); LayoutParams params = getWindow().getAttributes(); params.width = -1; params.height = -2; params.gravity = gravity; getWindow().setAttributes(params); } setContentView(view); }
Example #29
Source File: CallActivity.java From Yahala-Messenger with MIT License | 5 votes |
@Override public void onSensorChanged(SensorEvent event) { WindowManager.LayoutParams params = this.getWindow().getAttributes(); if (event.sensor.getType() == Sensor.TYPE_PROXIMITY) { if (event.values[0] == 0) { /* FileLog.d("onSensorChanged", "distance:" + event.values[0] + ""); params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON; params.screenBrightness = 0; getWindow().setAttributes(params);*/ if (!mProximityWakeLock.isHeld()) { mProximityWakeLock.acquire(); } } else { if (mProximityWakeLock.isHeld()) { mProximityWakeLock.release(); } /*params.flags |= LayoutParams.FLAG_KEEP_SCREEN_ON; params.screenBrightness = -1f; getWindow().setAttributes(params);*/ } /*try { // Yeah, this is hidden field. //int field = PowerManager.class.getClass().getField("PROXIMITY_SCREEN_OFF_WAKE_LOCK").getInt(null); } catch (Throwable ignored) { }*/ } }
Example #30
Source File: BaseDialog.java From AutoTest with MIT License | 5 votes |
/** show at location only valid for mIsPopupStyle true(指定位置显示,只对isPopupStyle为true有效) */ public void showAtLocation(int gravity, int x, int y) { if (mIsPopupStyle) { Window window = getWindow(); LayoutParams params = window.getAttributes(); window.setGravity(gravity); params.x = x; params.y = y; } show(); }