Android WindowManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android WindowManager class.

This code example shows how to use the following methods: setBackgroundDrawable, addView, addView
        onTouchInterceptor = l;
    } 
 
    @Implementation 
    public void showAsDropDown(View anchor) {
        containerView = new LinearLayout(context);
        containerView.addView(contentView);
        containerView.setBackgroundDrawable(background);
        getWindowManager().addView(containerView, null);
    } 
 
    @Implementation 
    public void showAsDropDown(View anchor, int xoff, int yoff) {
        xOffset = xoff;
        yOffset = yoff;
        showAsDropDown(anchor);
    } 
 
    public boolean dispatchTouchEvent(MotionEvent e) {
        return onTouchInterceptor != null && onTouchInterceptor.onTouch(realPopupWindow.getContentView(), e);
Full Snippet Info
8
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDefaultDisplay
     
    @Override 
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        // windowManager should not be null 
        windowManager.getDefaultDisplay();
        requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    } 
 
 
    @Click 
    void myButtonClicked() { 
        String name = myEditText.getText().toString();
        setProgressBarIndeterminateVisibility(true);
        someBackgroundWork(name, 5);
    } 
 
    @Background 
    void someBackgroundWork(String name, long timeToDoSomeLongComputation) {
        try { 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: addView
        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
        WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
        PixelFormat.TRANSPARENT);
       
    params.gravity=Gravity.FILL_HORIZONTAL|Gravity.FILL_VERTICAL;
    mgr.addView(v, params);
     
    // stopSelf(); -- uncomment for "component-less" operation 
  } 
 
  @Override 
  public IBinder onBind(Intent intent) {
    return(null); 
  } 
 
  @Override 
  public void onDestroy() { 
    mgr.removeView(v);  // comment out for "component-less" operation
     
    super.onDestroy(); 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: addView, removeView
            mParams.x = mX;
            mParams.y = mY;
            mParams.verticalMargin = mVerticalMargin;
            mParams.horizontalMargin = mHorizontalMargin;
            if (mView.getParent() != null) {
                mWM.removeView(mView);
            } 
            mWM.addView(mView, mParams);
        } 
    } 
 
    private synchronized void handleHide() { 
        if (mView != null) {
            // note: checking parent() just to make sure the view has 
            // been added...  i have seen cases where we get here when 
            // the view isn't yet added, so let's try not to crash. 
            if (mView.getParent() != null) {
                mWM.removeView(mView);
            } 
            mView = null;

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDefaultDisplay
        setOutsideTouchable(true);
        setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
        setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
 
        final WindowManager windowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
        mScreenWidth = windowManager.getDefaultDisplay().getWidth();
        mScreenHeight = windowManager.getDefaultDisplay().getHeight();
    } 
 
    /** 
     * Equivalent to {@link PopupWindow#setContentView(View)} but with a layout 
     * identifier. 
     *  
     * @param layoutId The layout identifier of the view to use. 
     */ 
    public void setContentView(int layoutId) {
        setContentView(LayoutInflater.from(mContext).inflate(layoutId, null));
    } 
 
    private void initializeDefault() { 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDefaultDisplay
 
	protected static DisplayMetrics getDisplayMetrics(View parent)
	{ 
		if (metrics == null) {
			WindowManager windowManager = (WindowManager) parent.getContext().getSystemService(Context.WINDOW_SERVICE);
			Display display = windowManager.getDefaultDisplay();
			metrics = new DisplayMetrics();
			display.getMetrics(metrics);
		} 
		return metrics;
	} 
 
	protected double getScaledPixels(View parent)
	{ 
		DisplayMetrics metrics = getDisplayMetrics(parent);
		if (units == TypedValue.COMPLEX_UNIT_DIP) {
			return (metrics.density * this.value);
		} else if (units == TypedValue.COMPLEX_UNIT_SP) {
			return (metrics.scaledDensity * this.value);
		} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: addView
        WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,
        WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
        PixelFormat.TRANSPARENT);
       
    params.gravity=Gravity.FILL_HORIZONTAL|Gravity.FILL_VERTICAL;
    mgr.addView(v, params);
     
    // stopSelf(); -- uncomment for "component-less" operation 
  } 
 
  @Override 
  public IBinder onBind(Intent intent) {
    return(null); 
  } 
 
  @Override 
  public void onDestroy() { 
    mgr.removeView(v);  // comment out for "component-less" operation
     
    super.onDestroy(); 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: updateViewLayout
        mDragView = v;
    } 
 
    private void dragView(int x, int y) {
        mWindowParams.y = y - mDragPoint + mCoordOffset;
        mWindowManager.updateViewLayout(mDragView, mWindowParams);
    } 
 
    private void stopDragging() { 
        if (mDragView != null) {
            mDragView.setVisibility(GONE);
            WindowManager wm = (WindowManager) getContext().getSystemService("window");
            wm.removeView(mDragView);
            mDragView.setImageDrawable(null);
            mDragView = null;
        } 
        if (mDragBitmap != null) {
            mDragBitmap.recycle();
            mDragBitmap = null;
        } 
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: getDefaultDisplay
context = theContext;
		 
		metrics = new DisplayMetrics();
		WindowManager windowManager = (WindowManager)context.getSystemService(Context.WINDOW_SERVICE);
		windowManager.getDefaultDisplay().getMetrics(metrics);
		 
		configuration = context.getResources().getConfiguration();
	} 
	 
	 
	/** 
	 * Gets the screen density. 
	 * @return								Screen density in DPI. 
	 */ 
	public int getScreenDensity() 
	{ 
		return metrics.densityDpi;
		 
	} 
Full Snippet Info
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods: addView, removeView
		} 
		if (y != -1) {
			wmParams.y = y;
		} 
 
		windowMgr.addView(view, wmParams);
	} 
 
	public void hide() { 
		windowMgr.removeView(view);
	} 
 
	public void setNewView(View view, int x, int y) {
		hide(); 
		initView(view);
		show(x, y);
	} 
 
	@Override 
	public boolean onTouch(View v, MotionEvent event) {
Full Snippet Info
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java

Related Android WindowManager Questions & Answers:

See Code Examples for Android WindowManager Methods: