Search in sources :

Example 26 with LayoutParams

use of android.view.WindowManager.LayoutParams in project platform_frameworks_base by android.

the class ZoomButtonsController method createContainer.

private FrameLayout createContainer() {
    LayoutParams lp = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    // Controls are positioned BOTTOM | CENTER with respect to the owner view.
    lp.gravity = Gravity.TOP | Gravity.START;
    lp.flags = LayoutParams.FLAG_NOT_TOUCHABLE | LayoutParams.FLAG_NOT_FOCUSABLE | LayoutParams.FLAG_LAYOUT_NO_LIMITS | LayoutParams.FLAG_ALT_FOCUSABLE_IM;
    lp.height = LayoutParams.WRAP_CONTENT;
    lp.width = LayoutParams.MATCH_PARENT;
    lp.type = LayoutParams.TYPE_APPLICATION_PANEL;
    lp.format = PixelFormat.TRANSLUCENT;
    lp.windowAnimations = com.android.internal.R.style.Animation_ZoomButtons;
    mContainerLayoutParams = lp;
    FrameLayout container = new Container(mContext);
    container.setLayoutParams(lp);
    container.setMeasureAllChildren(true);
    LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    inflater.inflate(com.android.internal.R.layout.zoom_container, container);
    mControls = (ZoomControls) container.findViewById(com.android.internal.R.id.zoomControls);
    mControls.setOnZoomInClickListener(new OnClickListener() {

        public void onClick(View v) {
            dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
            if (mCallback != null)
                mCallback.onZoom(true);
        }
    });
    mControls.setOnZoomOutClickListener(new OnClickListener() {

        public void onClick(View v) {
            dismissControlsDelayed(ZOOM_CONTROLS_TIMEOUT);
            if (mCallback != null)
                mCallback.onZoom(false);
        }
    });
    return container;
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) LayoutInflater(android.view.LayoutInflater) OnClickListener(android.view.View.OnClickListener) View(android.view.View)

Example 27 with LayoutParams

use of android.view.WindowManager.LayoutParams in project FlycoDialog_Master by H07000223.

the class BaseDialog method showAtLocation.

/** 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();
}
Also used : Window(android.view.Window) LayoutParams(android.view.WindowManager.LayoutParams)

Example 28 with LayoutParams

use of android.view.WindowManager.LayoutParams in project android_frameworks_base by AOSPA.

the class PopupWindow method update.

/**
     * Updates the position and the dimension of the popup window.
     * <p>
     * Width and height can be set to -1 to update location only. Calling this
     * function also updates the window with the current popup state as
     * described for {@link #update()}.
     *
     * @param x the new x location
     * @param y the new y location
     * @param width the new width in pixels, must be >= 0 or -1 to ignore
     * @param height the new height in pixels, must be >= 0 or -1 to ignore
     * @param force {@code true} to reposition the window even if the specified
     *              position already seems to correspond to the LayoutParams,
     *              {@code false} to only reposition if needed
     */
public void update(int x, int y, int width, int height, boolean force) {
    if (width >= 0) {
        mLastWidth = width;
        setWidth(width);
    }
    if (height >= 0) {
        mLastHeight = height;
        setHeight(height);
    }
    if (!isShowing() || mContentView == null) {
        return;
    }
    final WindowManager.LayoutParams p = (WindowManager.LayoutParams) mDecorView.getLayoutParams();
    boolean update = force;
    final int finalWidth = mWidthMode < 0 ? mWidthMode : mLastWidth;
    if (width != -1 && p.width != finalWidth) {
        p.width = mLastWidth = finalWidth;
        update = true;
    }
    final int finalHeight = mHeightMode < 0 ? mHeightMode : mLastHeight;
    if (height != -1 && p.height != finalHeight) {
        p.height = mLastHeight = finalHeight;
        update = true;
    }
    if (p.x != x) {
        p.x = x;
        update = true;
    }
    if (p.y != y) {
        p.y = y;
        update = true;
    }
    final int newAnim = computeAnimationResource();
    if (newAnim != p.windowAnimations) {
        p.windowAnimations = newAnim;
        update = true;
    }
    final int newFlags = computeFlags(p.flags);
    if (newFlags != p.flags) {
        p.flags = newFlags;
        update = true;
    }
    final int newGravity = computeGravity();
    if (newGravity != p.gravity) {
        p.gravity = newGravity;
        update = true;
    }
    int newAccessibilityIdOfAnchor = (mAnchor != null) ? mAnchor.get().getAccessibilityViewId() : -1;
    if (newAccessibilityIdOfAnchor != p.accessibilityIdOfAnchor) {
        p.accessibilityIdOfAnchor = newAccessibilityIdOfAnchor;
        update = true;
    }
    if (update) {
        setLayoutDirectionFromAnchor();
        mWindowManager.updateViewLayout(mDecorView, p);
    }
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) LayoutParams(android.view.WindowManager.LayoutParams) WindowManager(android.view.WindowManager)

Example 29 with LayoutParams

use of android.view.WindowManager.LayoutParams in project android_frameworks_base by AOSPA.

the class PopupWindow method dismiss.

/**
     * Disposes of the popup window. This method can be invoked only after
     * {@link #showAsDropDown(android.view.View)} has been executed. Failing
     * that, calling this method will have no effect.
     *
     * @see #showAsDropDown(android.view.View)
     */
public void dismiss() {
    if (!isShowing() || mIsTransitioningToDismiss) {
        return;
    }
    final PopupDecorView decorView = mDecorView;
    final View contentView = mContentView;
    final ViewGroup contentHolder;
    final ViewParent contentParent = contentView.getParent();
    if (contentParent instanceof ViewGroup) {
        contentHolder = ((ViewGroup) contentParent);
    } else {
        contentHolder = null;
    }
    // Ensure any ongoing or pending transitions are canceled.
    decorView.cancelTransitions();
    mIsShowing = false;
    mIsTransitioningToDismiss = true;
    // This method may be called as part of window detachment, in which
    // case the anchor view (and its root) will still return true from
    // isAttachedToWindow() during execution of this method; however, we
    // can expect the OnAttachStateChangeListener to have been called prior
    // to executing this method, so we can rely on that instead.
    final Transition exitTransition = mExitTransition;
    if (exitTransition != null && decorView.isLaidOut() && (mIsAnchorRootAttached || mAnchorRoot == null)) {
        // The decor view is non-interactive and non-IME-focusable during exit transitions.
        final LayoutParams p = (LayoutParams) decorView.getLayoutParams();
        p.flags |= LayoutParams.FLAG_NOT_TOUCHABLE;
        p.flags |= LayoutParams.FLAG_NOT_FOCUSABLE;
        p.flags &= ~LayoutParams.FLAG_ALT_FOCUSABLE_IM;
        mWindowManager.updateViewLayout(decorView, p);
        final View anchorRoot = mAnchorRoot != null ? mAnchorRoot.get() : null;
        final Rect epicenter = getTransitionEpicenter();
        // Once we start dismissing the decor view, all state (including
        // the anchor root) needs to be moved to the decor view since we
        // may open another popup while it's busy exiting.
        decorView.startExitTransition(exitTransition, anchorRoot, epicenter, new TransitionListenerAdapter() {

            @Override
            public void onTransitionEnd(Transition transition) {
                dismissImmediate(decorView, contentHolder, contentView);
            }
        });
    } else {
        dismissImmediate(decorView, contentHolder, contentView);
    }
    // Clears the anchor view.
    detachFromAnchor();
    if (mOnDismissListener != null) {
        mOnDismissListener.onDismiss();
    }
}
Also used : Rect(android.graphics.Rect) LayoutParams(android.view.WindowManager.LayoutParams) ViewGroup(android.view.ViewGroup) ViewParent(android.view.ViewParent) Transition(android.transition.Transition) TransitionListenerAdapter(android.transition.Transition.TransitionListenerAdapter) View(android.view.View)

Example 30 with LayoutParams

use of android.view.WindowManager.LayoutParams in project android_frameworks_base by DirtyUnicorns.

the class WindowStateAnimator method setWallpaperOffset.

void setWallpaperOffset(Point shownPosition) {
    final LayoutParams attrs = mWin.getAttrs();
    final int left = shownPosition.x - attrs.surfaceInsets.left;
    final int top = shownPosition.y - attrs.surfaceInsets.top;
    try {
        if (SHOW_LIGHT_TRANSACTIONS)
            Slog.i(TAG, ">>> OPEN TRANSACTION setWallpaperOffset");
        SurfaceControl.openTransaction();
        mSurfaceController.setPositionInTransaction(mWin.mFrame.left + left, mWin.mFrame.top + top, false);
        calculateSurfaceWindowCrop(mTmpClipRect, mTmpFinalClipRect);
        updateSurfaceWindowCrop(mTmpClipRect, mTmpFinalClipRect, false);
    } catch (RuntimeException e) {
        Slog.w(TAG, "Error positioning surface of " + mWin + " pos=(" + left + "," + top + ")", e);
    } finally {
        SurfaceControl.closeTransaction();
        if (SHOW_LIGHT_TRANSACTIONS)
            Slog.i(TAG, "<<< CLOSE TRANSACTION setWallpaperOffset");
    }
}
Also used : LayoutParams(android.view.WindowManager.LayoutParams) Point(android.graphics.Point)

Aggregations

LayoutParams (android.view.WindowManager.LayoutParams)46 View (android.view.View)19 Point (android.graphics.Point)10 Rect (android.graphics.Rect)8 OnClickListener (android.view.View.OnClickListener)8 LayoutInflater (android.view.LayoutInflater)7 Transition (android.transition.Transition)5 TransitionListenerAdapter (android.transition.Transition.TransitionListenerAdapter)5 ViewGroup (android.view.ViewGroup)5 ViewParent (android.view.ViewParent)5 WindowManager (android.view.WindowManager)5 Window (android.view.Window)3 Canvas (android.graphics.Canvas)2 Surface (android.view.Surface)2 Animation (android.view.animation.Animation)2 TargetApi (android.annotation.TargetApi)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 EpicenterCallback (android.transition.Transition.EpicenterCallback)1 Display (android.view.Display)1