@Override public void onCreate() { super.onCreate(); sp = getSharedPreferences("date", 0); sp_setting = PreferenceManager.getDefaultSharedPreferences(this); sp_userinfo = getSharedPreferences("userinfo", 0); C.FRAME = Integer.parseInt(sp_setting.getString("Frame", "60")); Wm = (WindowManager) getApplication().getSystemService(Context.WINDOW_SERVICE); wmParams = new WindowManager.LayoutParams(); wmParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; // 设置悬浮窗为全屏 wmParams.flags = 1280; wmParams.format = PixelFormat.RGBA_8888; wmParams.alpha = 0.8f; wmParams.gravity = Gravity.LEFT | Gravity.BOTTOM; wmParams.width = ViewGroup.LayoutParams.MATCH_PARENT; wmParams.height = ViewGroup.LayoutParams.MATCH_PARENT; Wm_control = (WindowManager) getApplication().getSystemService(Context.WINDOW_SERVICE); wmParams_control = new WindowManager.LayoutParams(); wmParams_control.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; wmParams_control.format = PixelFormat.RGB_888; wmParams_control.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; wmParams_control.alpha = 0; wmParams_control.width = 0; wmParams_control.height = 0; win_control = new View(this); Wm_control.addView(win_control, wmParams_control); // 注册系统广播 sr = new ScreenReceiver(); sr.registerScreenActionReceiver(MSSService.this); registerBattery(); // 注册自己程序的广播 IntentFilter inf = new IntentFilter(); inf.addAction("com.jiusg.mainscreenshow"); mssr = new MSSReceiver(); registerReceiver(mssr, inf); sa_IsEvent = new SparseBooleanArray(); sa_Animation = new SparseArray<Integer>(); animManage = new AnimationManage(Wm, wmParams, getApplicationContext()); isView = false; mHandler = new MssHandler(); imageCache = new ImageCache(getApplicationContext()); AVAnalytics.onEvent(MSSService.this, "Server Create", TAG); startService(new Intent(this, MSSLiveWallpaper.class)); }
private void applyHeight(State state) { boolean expanded = isExpanded(state); if (expanded) { mLpChanged.height = ViewGroup.LayoutParams.MATCH_PARENT; } else { mLpChanged.height = mBarHeight; } }
protected void b() { c = new je(this, a); b = new WindowManager.LayoutParams(); b.width = -1; b.height = -1; b.format = -2; c.setVisibility(8); c.setBackgroundDrawable(null); c.setOnClickListener(new jf(this)); if (e) { g = new jg(this, a, h); c.setGravity(53); LinearLayout.LayoutParams localLayoutParams = new LinearLayout.LayoutParams(-2, -2); if ((a instanceof jb)) { Rect localRect1 = ((jb) a).t(); if (localRect1 != null) { Rect localRect2 = new Rect(); ((Activity) a).getWindow().getDecorView().getWindowVisibleDisplayFrame(localRect2); int k = top; height = localRect1.height(); topMargin = (top - k); } } c.addView(g.a(), localLayoutParams); return; } g = new jh(this, a, h); c.setGravity(17); c.addView(g.a()); }
public void update(int x, int y, int width, int height) { if (width != -1) setWidth(width); if (height != -1) setHeight(height); if (!isShowing() || mContentView == null) return; android.view.WindowManager.LayoutParams p = (android.view.WindowManager.LayoutParams) mContentView.getLayoutParams(); boolean update = false; if (width != -1 && p.width != width) { p.width = width; update = true; } if (height != -1 && p.height != height) { p.height = height; update = true; } if (p.x != x) { p.x = x; update = true; } if (p.y != y) { p.y = y; update = true; } if (update) { WindowManagerImpl wm = WindowManagerImpl.getDefault(); wm.updateViewLayout(mContentView, p); } }
/** 自定义归属地浮窗 */ private void showToast(String string) { windowManager = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.height = WindowManager.LayoutParams.WRAP_CONTENT; params.width = WindowManager.LayoutParams.WRAP_CONTENT; params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; params.format = PixelFormat.TRANSLUCENT; params.type = WindowManager.LayoutParams.TYPE_TOAST; params.setTitle("Toast"); view = View.inflate(this, R.layout.toast_layout, null); int[] bgs = new int[] { R.drawable.call_locate_white, R.drawable.call_locate_orange, R.drawable.call_locate_blue, R.drawable.call_locate_gray, R.drawable.call_locate_green }; int style = getSharedPreferences("config", MODE_PRIVATE).getInt("address_style", 0); TextView textView = (TextView) view.findViewById(R.id.tv_number); view.setBackgroundResource(bgs[style]); textView.setText(string); windowManager.addView(view, params); }
/** * 打开单选框 * * @param context 上下文 */ public static AlertDialog showWaiting(Context context) { final AlertDialog alertDialog = new AlertDialog.Builder(context).create(); alertDialog.show(); Window window = alertDialog.getWindow(); WindowManager.LayoutParams layoutParams = window.getAttributes(); layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT; window.setGravity(Gravity.CENTER); window.setAttributes(layoutParams); window.setContentView(R.layout.dialog_waiting); ViewGroup background = (ViewGroup) window.findViewById(R.id.waiting_layout_background); background.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { // alertDialog.cancel(); } }); ImageView icon = (ImageView) window.findViewById(R.id.waiting_image_icon); final RotateAnimation animation = new RotateAnimation( 0f, 720f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); animation.setDuration(2000); animation.setRepeatCount(Animation.INFINITE); icon.startAnimation(animation); return alertDialog; }
void displayEula() { AlertDialog.Builder adb = new SimpleEula(this).show(); if (adb != null) { Dialog dialog = adb.create(); Display display = getWindowManager().getDefaultDisplay(); int mwidth = display.getWidth(); int mheight = display.getHeight(); dialog.show(); int apiLevel = getApiLevel(); if (apiLevel >= 11) { WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = mwidth; lp.height = mheight; lp.gravity = Gravity.CENTER_VERTICAL; lp.dimAmount = 0.7f; dialog.getWindow().setAttributes(lp); dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); } } }
/** 学院 */ private void showCademyDialog() { final AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setTitle("学院") .setItems( R.array.cademys, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // user.job = which; // action_done(); curUser.setCademy(getResources().getStringArray(R.array.cademys)[which]); aq.id(R.id.et_mineinfo_cademy).text(curUser.getCademy()); } }); // builder.create().show(); WindowManager m = getWindowManager(); Display d = m.getDefaultDisplay(); AlertDialog dialog = builder.create(); dialog.show(); WindowManager.LayoutParams p = dialog.getWindow().getAttributes(); Point outSize = new Point(); d.getSize(outSize); p.height = (int) (outSize.y * 0.6); // 高度设置为屏幕的0.6 // p.width = (int) (d.getWidth() * 0.8); dialog.getWindow().setAttributes(p); dialogTitleLineColor(dialog); }
private void startDragging(Bitmap bm, int x, int y) { stopDragging(); mWindowParams = new WindowManager.LayoutParams(); mWindowParams.gravity = Gravity.TOP | Gravity.LEFT; mWindowParams.x = x; mWindowParams.y = y - mDragPoint + mCoordOffset; mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; mWindowParams.format = PixelFormat.TRANSLUCENT; mWindowParams.windowAnimations = 0; Context context = getContext(); ImageView v = new ImageView(context); int backGroundColor = context.getResources().getColor(android.R.color.holo_blue_dark); v.setAlpha((float) 0.7); v.setBackgroundColor(backGroundColor); v.setImageBitmap(bm); mDragBitmap = bm; mWindowManager = (WindowManager) context.getSystemService("window"); mWindowManager.addView(v, mWindowParams); mDragView = v; }
/** * Prepare the popup by embedding in into a new ViewGroup if the background drawable is not null. * If embedding is required, the layout parameters' height is mnodified to take into account the * background's padding. * * @param p the layout parameters of the popup's content view */ private void preparePopup(WindowManager.LayoutParams p) { if (mBackground != null) { // when a background is available, we embed the content view // within another view that owns the background drawable PopupViewContainer popupViewContainer = new PopupViewContainer(mContext); PopupViewContainer.LayoutParams listParams = new PopupViewContainer.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT); popupViewContainer.setBackgroundDrawable(mBackground); popupViewContainer.addView(mContentView, listParams); if (p.height >= 0) { // accomodate the popup's height to take into account the // background's padding p.height += popupViewContainer.getPaddingTop() + popupViewContainer.getPaddingBottom(); } if (p.width >= 0) { // accomodate the popup's width to take into account the // background's padding p.width += popupViewContainer.getPaddingLeft() + popupViewContainer.getPaddingRight(); } mPopupView = popupViewContainer; } else { mPopupView = mContentView; } mPopupWidth = p.width; mPopupHeight = p.height; }
@AfterViews void init() { // 设置ErrorHandler userApi.setRestErrorHandler(errorHandlerForUserService); ExitApplication.getInstance().addActivity(this); inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); views = inflater.inflate( // 获取自定义布局文件dialog.xml的视图 R.layout.activity_modifyname, null, false); app = (CustomApplication) getApplication(); userId = app.getUserId(); intent = getIntent(); // 获取修改前性别 this.oldSex = app.getUserSex(); if (this.oldSex.equals("男")) { this.imageViewMan.setImageResource(R.drawable.defalt_head); } else { this.imageViewWoman.setImageResource(R.drawable.defalt_head); } // 初始化界面 Window window = getWindow(); WindowManager.LayoutParams layoutParams = window.getAttributes(); // 设置窗口的大小及透明度 layoutParams.width = WindowManager.LayoutParams.WRAP_CONTENT; layoutParams.height = layoutParams.WRAP_CONTENT; window.setAttributes(layoutParams); this.setFinishOnTouchOutside(true); }
private void initView() { mWM = (WindowManager) mContext.getSystemService(WINDOW_SERVICE); mTextView = new TextView(mContext) { @Override protected void onDraw(android.graphics.Canvas canvas) { int t = getTop(); int l = getLeft(); int b = getBottom(); int r = getRight(); mRect.top = t; mRect.left = t; mRect.right = r; mRect.bottom = b; canvas.drawRect(mRect, mPaint); super.onDraw(canvas); }; }; WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.type = 2002; // wmParams.format=1; lp.flags |= 8; lp.gravity = Gravity.LEFT | Gravity.TOP; // 调整悬浮窗口至左上角 // 以屏幕左上角为原点,设置x、y初始值 lp.x = 0; lp.y = 0; // 设置悬浮窗口长宽数据 lp.width = 300; lp.height = 25; mTextView.setText(""); mWM.addView(mTextView, lp); }
private void startDragging(Bitmap bm, int y) { stopDragging(); mWindowParams = new WindowManager.LayoutParams(); mWindowParams.gravity = Gravity.TOP; mWindowParams.x = 0; mWindowParams.y = y - mDragPoint + mCoordOffset; mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; mWindowParams.format = PixelFormat.TRANSLUCENT; mWindowParams.windowAnimations = 0; ImageView v = new ImageView(getContext()); // int backGroundColor = // getContext().getResources().getColor(R.color.dragndrop_background); v.setBackgroundColor(dragndropBackgroundColor); v.setImageBitmap(bm); mDragBitmap = bm; mWindowManager = (WindowManager) getContext().getSystemService("window"); mWindowManager.addView(v, mWindowParams); mDragView = v; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getWindow() .setFlags( WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); this.requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.detailexplain_store); wm = this.getWindow().getAttributes(); wm.height = 740; wm.width = 793; initData(); closeButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { dismiss(); } }); buyButton.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { // 현재 포인트에서 물건 포인트 빼기 등등 처리 해야함 dismiss(); // 다이얼로그 종료 } }); }
private synchronized void handleShow() { if (mView != mNextView) { // remove the old view if necessary handleHide(); mView = mNextView; // / M: we set hint center_horizontal and bottom in xml. // final int gravity = mGravity; // mParams.gravity = gravity; // if ((gravity & Gravity.HORIZONTAL_GRAVITY_MASK) // == Gravity.FILL_HORIZONTAL) { // mParams.horizontalWeight = 1.0f; // } // if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) // == Gravity.FILL_VERTICAL) { // mParams.verticalWeight = 1.0f; // } // mParams.x = mX; // mParams.y = mY; // mParams.verticalMargin = mVerticalMargin; // mParams.horizontalMargin = mHorizontalMargin; mParams.x = 0; mParams.y = 0; mParams.height = WindowManager.LayoutParams.MATCH_PARENT; mParams.width = WindowManager.LayoutParams.MATCH_PARENT; try { if (mView.getParent() != null) { mWM.removeView(mView); } mWM.addView(mView, mParams); } catch (BadTokenException ex) { ex.printStackTrace(); } Util.fadeIn(mView); } }
@Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); WindowManager manager = ((WindowManager) cordova.getActivity().getApplicationContext().getSystemService(Context.WINDOW_SERVICE)); WindowManager.LayoutParams localLayoutParams = new WindowManager.LayoutParams(); localLayoutParams.type = WindowManager.LayoutParams.TYPE_SYSTEM_ERROR; localLayoutParams.gravity = Gravity.TOP; localLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | // this is to enable the notification to recieve touch events WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL | // Draws over status bar WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; localLayoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; localLayoutParams.height = (int) (30 * cordova.getActivity().getResources().getDisplayMetrics().scaledDensity); localLayoutParams.format = PixelFormat.TRANSPARENT; CustomViewGroup view = new CustomViewGroup(cordova.getActivity().getApplicationContext()); manager.addView(view, localLayoutParams); }
/** * Show the controller on screen. It will go away automatically after 'timeout' milliseconds of * inactivity. * * @param timeout The timeout in milliseconds. Use 0 to show the controller until hide() is * called. */ public void show(int timeout) { if (!mShowing && mAnchor != null) { setProgress(); int[] anchorpos = new int[2]; mAnchor.getLocationOnScreen(anchorpos); WindowManager.LayoutParams p = new WindowManager.LayoutParams(); p.gravity = Gravity.TOP; p.width = mAnchor.getWidth(); p.height = LayoutParams.WRAP_CONTENT; p.x = 0; p.y = anchorpos[1] + mAnchor.getHeight() - p.height; p.format = PixelFormat.TRANSLUCENT; p.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL; p.flags |= WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM; p.token = null; p.windowAnimations = 0; // android.R.style.DropDownAnimationDown; mWindowManager.addView(mDecor, p); mShowing = true; } updatePausePlay(); // cause the progress bar to be updated even if mShowing // was already true. This happens, for example, if we're // paused with the progress bar showing the user hits play. mHandler.sendEmptyMessage(SHOW_PROGRESS); Message msg = mHandler.obtainMessage(FADE_OUT); if (timeout != 0) { mHandler.removeMessages(FADE_OUT); mHandler.sendMessageDelayed(msg, timeout); } }
public void removeNote() { if (config.notes.size() <= 0) return; boolean removing = false; int noteCount = 0; for (int i = 0; i < config.notes.size(); i++) { SteamHUDNote note = config.notes.get(i); if (!note.removing) { noteCount = config.notes.size() - i - 1; note.removing = true; break; } else if (i == config.notes.size() - 1) { return; } } WindowManager.LayoutParams params = (WindowManager.LayoutParams) getLayoutParams(); WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE); params.height = (int) (74 * noteCount * config.scaleFactor) + 1; wm.updateViewLayout(this, params); config.hudRender.invalidate(); }
private void startDragging(Bitmap bm, int x, int y) { stopDragging(); mWindowParams = new WindowManager.LayoutParams(); mWindowParams.gravity = Gravity.TOP | Gravity.LEFT; mWindowParams.x = x - mDragPointX + mXOffset; mWindowParams.y = y - mDragPointY + mYOffset; mWindowParams.height = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.width = WindowManager.LayoutParams.WRAP_CONTENT; mWindowParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS; mWindowParams.format = PixelFormat.TRANSLUCENT; mWindowParams.windowAnimations = 0; Context context = getContext(); ImageView v = new ImageView(context); // int backGroundColor = context.getResources().getColor(R.color.dragndrop_background); v.setBackgroundColor(0x882211); // !!toa // v.setBackgroundResource(R.drawable.playlist_tile_drag); v.setPadding(0, 0, 0, 0); v.setImageBitmap(bm); mDragBitmap = bm; mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); mWindowManager.addView(v, mWindowParams); mDragView = v; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WindowManager.LayoutParams params = getWindow().getAttributes(); params.height = ViewGroup.LayoutParams.MATCH_PARENT; params.width = ViewGroup.LayoutParams.MATCH_PARENT; getWindow().setAttributes((android.view.WindowManager.LayoutParams) params); }
protected void reduceToTriggerRegion() { mLayoutParams = (WindowManager.LayoutParams) getLayoutParams(); mLayoutParams.y = mTriggerTop; mLayoutParams.height = mTriggerBottom; mLayoutParams.width = mTriggerWidth; mLayoutParams.flags = disableKeyEvents(); mWM.updateViewLayout(this, mLayoutParams); }
public void setSize() { Window window = TurnkeyCommFinetune.this.getWindow(); Display d = window.getWindowManager().getDefaultDisplay(); WindowManager.LayoutParams p = window.getAttributes(); p.height = (int) (d.getHeight()); p.width = (int) (d.getWidth()); window.setAttributes(p); }
public static void setActivitySizePos(Activity activity, int x, int y, int width, int height) { WindowManager.LayoutParams p = activity.getWindow().getAttributes(); p.x = x; p.y = y; p.width = width; p.height = height; activity.getWindow().setAttributes(p); }
@Override /** 监听电话状态 */ public void onCallStateChanged(int state, String incomingNumber) { // TODO Auto-generated method stub super.onCallStateChanged(state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_RINGING: if (serviceState) { boolean falg = new BlackNumDao(ShowAddressService.this).find(incomingNumber); if (falg) { ringOff(); getContentResolver() .registerContentObserver( CallLog.Calls.CONTENT_URI, true, new CallLogChangeObserver(new Handler(), incomingNumber)); return; } } String value = AddressService.getAddressService(incomingNumber); view = inflater.inflate(R.layout.show_phone_address, null); TextView address_tv = (TextView) view.findViewById(R.id.show_phone_address_address); TextView phone_tv = (TextView) view.findViewById(R.id.show_phone_address_phone); address_tv.setText(value); String phoneName = new MyContentProvider(ShowAddressService.this).getPhoneName(incomingNumber); if (phoneName != null) { phone_tv.setText(phoneName); } else { phone_tv.setText(incomingNumber); } WindowManager.LayoutParams params = new LayoutParams(); params.height = WindowManager.LayoutParams.WRAP_CONTENT + 70; params.width = WindowManager.LayoutParams.WRAP_CONTENT + 200; params.y = params.y + 23; new Thread(new SaveParamsCoord(params.x, params.y, params.width, params.height)).start(); params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON; params.format = PixelFormat.TRANSLUCENT; params.type = WindowManager.LayoutParams.TYPE_TOAST; params.setTitle("Toast"); windowManager.addView(view, params); break; case TelephonyManager.CALL_STATE_IDLE: if (view != null) { windowManager.removeView(view); view = null; } default: break; } }
protected void setBottomPercentage(float value) { mLayoutParams = (WindowManager.LayoutParams) this.getLayoutParams(); mTriggerBottom = (int) (mViewHeight * value); mLayoutParams.height = mTriggerBottom; try { mWM.updateViewLayout(this, mLayoutParams); } catch (Exception e) { } }
@Override public void show() { super.show(); getWindow().setBackgroundDrawableResource(android.R.color.transparent); WindowManager.LayoutParams lp = getWindow().getAttributes(); lp.width = DisplayLess.$dp2px(160); lp.height = DisplayLess.$dp2px(160); getWindow().setAttributes(lp); }
/** @Method: showTopWindow @Description: 显示最顶层view */ public void showTopWindow(Activity c) { this.a = c; View views = null; if (PadUtils.isPad(this)) { views = LayoutInflater.from(this).inflate(R.layout.pad_splash_screen, null); } else { views = LayoutInflater.from(this).inflate(R.layout.phone_splash_screen, null); } WindowManager windowManager = (WindowManager) getApplicationContext().getSystemService(WINDOW_SERVICE); WindowManager.LayoutParams params = new WindowManager.LayoutParams(); params.type = WindowManager.LayoutParams.TYPE_SYSTEM_ALERT | WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY; int screenWidth = windowManager.getDefaultDisplay().getWidth(); int screenHeight = windowManager.getDefaultDisplay().getHeight(); // 屏幕高 params.x = 0; params.y = 0; params.width = screenWidth; if (PadUtils.isPad(this)) { params.height = screenHeight; } else { params.height = screenHeight - getStatusHeight(c); } final View view = views; // topWindow显示到最顶部 windowManager.addView(view, params); new Thread( new Runnable() { @Override public void run() { try { Thread.sleep(2400); clearTopWindow(view); } catch (InterruptedException e) { e.printStackTrace(); } } }) .start(); }
@Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); getWindow().setGravity(Gravity.CENTER); WindowManager m = getWindow().getWindowManager(); Display d = m.getDefaultDisplay(); WindowManager.LayoutParams p = getWindow().getAttributes(); p.width = ViewGroup.LayoutParams.MATCH_PARENT; p.height = ViewGroup.LayoutParams.MATCH_PARENT; getWindow().setAttributes(p); }
private void updateLayoutParamsForPosiion( View anchor, WindowManager.LayoutParams p, int yOffset) { measureFloater(); int measuredHeight = mPopupView.getMeasuredHeight(); int paddingBottom = mPopupView.mMarker.getPaddingBottom(); anchor.getLocationInWindow(mDrawingLocation); p.x = 0; p.y = mDrawingLocation[1] - measuredHeight + yOffset + paddingBottom; p.width = screenSize.x; p.height = measuredHeight; }
protected void expandFromTriggerRegion() { mLayoutParams = (WindowManager.LayoutParams) getLayoutParams(); mLayoutParams.y = 0; Rect r = new Rect(); getWindowVisibleDisplayFrame(r); mViewHeight = r.bottom - r.top; mLayoutParams.height = mViewHeight; mLayoutParams.width = LayoutParams.MATCH_PARENT; mLayoutParams.flags = enableKeyEvents(); mWM.updateViewLayout(this, mLayoutParams); }