Java Code Examples for android.widget.AbsoluteLayout#LayoutParams

The following examples show how to use android.widget.AbsoluteLayout#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: Slider.java    From MHViewer with Apache License 2.0 6 votes vote down vote up
private void updateBubbleSize() {
    int oldWidth = mBubbleWidth;
    int oldHeight = mBubbleHeight;
    mBubbleWidth = (int) Math.max(mBubbleMinWidth,
            Integer.toString(mEnd).length() * mCharWidth + LayoutUtils.dp2pix(mContext, 8));
    mBubbleHeight = (int) Math.max(mBubbleMinHeight,
            mCharHeight + LayoutUtils.dp2pix(mContext, 8));

    if (oldWidth != mBubbleWidth && oldHeight != mBubbleHeight) {
        //noinspection deprecation
        AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) mBubble.getLayoutParams();
        lp.width = mBubbleWidth;
        lp.height = mBubbleHeight;
        mBubble.setLayoutParams(lp);
    }
}
 
Example 2
Source File: Slider.java    From EhViewer with Apache License 2.0 6 votes vote down vote up
private void updateBubbleSize() {
    int oldWidth = mBubbleWidth;
    int oldHeight = mBubbleHeight;
    mBubbleWidth = (int) Math.max(mBubbleMinWidth,
            Integer.toString(mEnd).length() * mCharWidth + LayoutUtils.dp2pix(mContext, 8));
    mBubbleHeight = (int) Math.max(mBubbleMinHeight,
            mCharHeight + LayoutUtils.dp2pix(mContext, 8));

    if (oldWidth != mBubbleWidth && oldHeight != mBubbleHeight) {
        //noinspection deprecation
        AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) mBubble.getLayoutParams();
        lp.width = mBubbleWidth;
        lp.height = mBubbleHeight;
        mBubble.setLayoutParams(lp);
    }
}
 
Example 3
Source File: NodeGroupLayout.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
private boolean calcLayoutParams(AbsoluteLayout.LayoutParams params, Tree.TreeNode node, Rect parentBoundsInScreen) {
    Rect boundsInScreen = node.getBoundsInScreen();
    Rect boundsInParent = new Rect(boundsInScreen); //TODO pool
    if (!mIsRoot) {
        boundsInParent.offset(-parentBoundsInScreen.left, -parentBoundsInScreen.top); //calculate the real bounds in parent.
    }


    boolean changed = false;

    if (params.x != boundsInParent.left || params.y != boundsInParent.top || params.width != boundsInParent.width() || params.height != boundsInParent.height()) {
        params.x = boundsInParent.left;
        params.y = boundsInParent.top;
        params.width = boundsInParent.width();
        params.height = boundsInParent.height();
        changed = true;
    }

    return changed;


}
 
Example 4
Source File: Slider.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
private void updateBubbleSize() {
    int oldWidth = mBubbleWidth;
    int oldHeight = mBubbleHeight;
    mBubbleWidth = (int) Math.max(mBubbleMinWidth,
            Integer.toString(mEnd).length() * mCharWidth + LayoutUtils.dp2pix(mContext, 8));
    mBubbleHeight = (int) Math.max(mBubbleMinHeight,
            mCharHeight + LayoutUtils.dp2pix(mContext, 8));

    if (oldWidth != mBubbleWidth && oldHeight != mBubbleHeight) {
        //noinspection deprecation
        AbsoluteLayout.LayoutParams lp = (AbsoluteLayout.LayoutParams) mBubble.getLayoutParams();
        lp.width = mBubbleWidth;
        lp.height = mBubbleHeight;
        mBubble.setLayoutParams(lp);
    }
}
 
Example 5
Source File: NodeTextView.java    From oversec with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void update(Tree.TreeNode node, Rect parentBoundsInScreen) {
    mUnused = false;
    mNode.recycle(false);
    mNode = node;


    //--------------------- update layout / dimensions

    AbsoluteLayout.LayoutParams params = (AbsoluteLayout.LayoutParams) getLayoutParams();
    boolean changed = calcLayoutParams(params, node, parentBoundsInScreen);
    if (changed) {
        setLayoutParams(params);
    }


    //----------------------- update contents

    readNodeInfo(false);
}
 
Example 6
Source File: FullScreenPopupWindow.java    From fuckView with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 上层View点击后会使下层接收不到事件,这里用了一种极其愚蠢的方法...
 *
 * @param x x axis
 * @param y y axis
 * @return
 */

private View getTouchView(int x, int y) {
    View v = null;
    AbsoluteLayout.LayoutParams minParam = null;
    for (int i = 0; i < absoluteLayout.getChildCount(); i++) {
        View view = absoluteLayout.getChildAt(i);

        AbsoluteLayout.LayoutParams param = (AbsoluteLayout.LayoutParams) view.getLayoutParams();
        if (x >= param.x && x <= (param.x + param.width)) {
            if (y >= param.y && y <= (param.y + param.height)) {
                if (v == null || (minParam.height * minParam.width > param.width * param.height)) {
                    v = view;
                    minParam = param;
                }
            }
        }
    }
    return v;
}
 
Example 7
Source File: AmbilWarnaDialog.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
protected void letakkanKeker() {
    float x = this.sat * this.ukuranUiPx;
    float y = (1.f - this.val) * this.ukuranUiPx;

    AbsoluteLayout.LayoutParams layoutParams = (AbsoluteLayout.LayoutParams) this.viewKeker
            .getLayoutParams();
    layoutParams.x = (int) (x + 3);
    layoutParams.y = (int) (y + 3);
    this.viewKeker.setLayoutParams(layoutParams);
}
 
Example 8
Source File: AmbilWarnaDialog.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
protected void letakkanPanah() {
    float y = this.ukuranUiPx - (this.hue * this.ukuranUiPx / 360.f);
    if (y == this.ukuranUiPx) {
        y = 0.f;
    }

    AbsoluteLayout.LayoutParams layoutParams = (AbsoluteLayout.LayoutParams) this.panah
            .getLayoutParams();
    layoutParams.y = (int) (y + 4);
    this.panah.setLayoutParams(layoutParams);
}
 
Example 9
Source File: MainActivity.java    From Jreader with GNU General Public License v2.0 5 votes vote down vote up
public void closeBookAnimation() {

        if (mIsOpen && wmRootView!=null) {
            //因为书本打开后会移动到第一位置,所以要设置新的位置参数
            contentAnimation.setmPivotXValue(bookShelf.getFirstLocation()[0]);
            contentAnimation.setmPivotYValue(bookShelf.getFirstLocation()[1]);
            coverAnimation.setmPivotXValue(bookShelf.getFirstLocation()[0]);
            coverAnimation.setmPivotYValue(bookShelf.getFirstLocation()[1]);

            AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams(
                    itemTextView.getLayoutParams());
            params.x = bookShelf.getFirstLocation()[0];
            params.y = bookShelf.getFirstLocation()[1];//firstLocation[1]在滑动的时候回改变,所以要在dispatchDraw的时候获取该位置值
            wmRootView.updateViewLayout(cover,params);
            wmRootView.updateViewLayout(content,params);
            //动画逆向运行
            if (!contentAnimation.getMReverse()) {
                contentAnimation.reverse();
            }
            if (!coverAnimation.getMReverse()) {
                coverAnimation.reverse();
            }
            //清除动画再开始动画
            content.clearAnimation();
            content.startAnimation(contentAnimation);
            cover.clearAnimation();
            cover.startAnimation(coverAnimation);
        }
    }
 
Example 10
Source File: FullScreenPopupWindow.java    From fuckView with GNU Affero General Public License v3.0 5 votes vote down vote up
private void init(final Context context) {


        for (ViewDumper.ViewItem item : list) {
            TextView tv = new TextView(context);
            tv.setTag(item);
            //红框
            GradientDrawable redBounds = new GradientDrawable();
            redBounds.setStroke(2, Color.RED);
            redBounds.setColor(Color.TRANSPARENT);
            tv.setBackgroundDrawable(redBounds);
            AbsoluteLayout.LayoutParams layoutParams = new AbsoluteLayout.LayoutParams(item.wh.x, item.wh.y, item.bounds.x, item.bounds.y - getStatusBarHeight());
            absoluteLayout.addView(tv, layoutParams);
        }
    }
 
Example 11
Source File: NodeTextView.java    From oversec with GNU General Public License v3.0 5 votes vote down vote up
public void setRightDrawableWidthChecked(int width) {
    if (mRightDrawableWidth != width) {

        AbsoluteLayout.LayoutParams params = (AbsoluteLayout.LayoutParams) getLayoutParams();
        params.width = params.width - mRightDrawableWidth + width;
        setLayoutParams(params);
        mRightDrawableWidth = width;
    }


}
 
Example 12
Source File: NodeGroupLayout.java    From oversec with GNU General Public License v3.0 5 votes vote down vote up
public void makeSpaceAbove(int px) {
    AbsoluteLayout.LayoutParams lp = (LayoutParams) getLayoutParams();
    lp.y = lp.y - px;
    if (lp.y < 0) {
        ViewParent vp = getParent();
        if (vp != null && vp instanceof NodeGroupLayout) {
            NodeGroupLayout parent = (NodeGroupLayout) vp;
            parent.makeSpaceAbove(-lp.y);
            lp.y = 0;
        }
    }
    lp.height = lp.height + px;
    setLayoutParams(lp);
}
 
Example 13
Source File: NodeGroupLayout.java    From oversec with GNU General Public License v3.0 5 votes vote down vote up
public NodeGroupLayout(boolean isRoot, Core core, Tree.TreeNode node, Rect parentBoundsInScreen, OverlayDecryptView overlayDecryptView, CryptoHandlerFacade cryptoHandlerFacade) {
    super(core.getCtx());
    mIsRoot = isRoot;
    mCore = core;
    mNode = node;
    mOverlayDecryptView = overlayDecryptView;
    mCryptoHandlerFacade = cryptoHandlerFacade;

    //--------------------- update layout / dimensions

    AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams(0, 0, 0, 0);
    calcLayoutParams(params, node, parentBoundsInScreen);
    setLayoutParams(params);


    //----------------------- update contents
    // setBackgroundColor(Color.parseColor("#3300FF00"));

    int cc = node.getChildCount();
    for (int i = 0; i < cc; i++) {
        View childView = null;
        if (node.getChildAt(i).isTextNode()) {
            childView = new NodeTextView(mCore, node.getChildAt(i), node.getBoundsInScreen(), overlayDecryptView, cryptoHandlerFacade);
        } else {
            childView = new NodeGroupLayout(mCore, node.getChildAt(i), node.getBoundsInScreen(), overlayDecryptView, cryptoHandlerFacade);
        }
        addView(childView);
    }


}
 
Example 14
Source File: HWWebView.java    From RePlugin-GameSdk with Apache License 2.0 5 votes vote down vote up
@SuppressLint("SetJavaScriptEnabled")
@SuppressWarnings("deprecation")
public HWWebView(Context context) {
	super(context);
	mMebView=this;
	this.mContext = context;

	int screenWidth = ((Activity) context).getWindowManager()
			.getDefaultDisplay().getWidth(); // 屏幕宽(像素,如:480px)
	int screenHeight = ((Activity) context).getWindowManager()
			.getDefaultDisplay().getHeight(); // 屏幕高(像素,如:800p)

	progressBar = new ProgressBar(context, null,
			android.R.attr.progressBarStyle);
	progressBar.setVisibility(View.GONE);

	AbsoluteLayout.LayoutParams progressBarParams = new AbsoluteLayout.LayoutParams(
			60, 60, (screenWidth - 60) / 2, (screenHeight - 60) / 2);

	this.addView(progressBar, progressBarParams);

	WebSettings set = this.getSettings();
	set.setSavePassword(false);
	set.setSaveFormData(false);
	set.setJavaScriptEnabled(true);
	set.setJavaScriptCanOpenWindowsAutomatically(true);

	this.setWebViewClient(new HWWebViewClient());
}
 
Example 15
Source File: NodeTextView.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
private boolean calcLayoutParams(AbsoluteLayout.LayoutParams in, Tree.TreeNode node, Rect parentBoundsInScreen) {
    //render the overlay right ABOVE the edit text so that we can clearly see what is actualy being sent!
    boolean above = isFocusedEditableText() && mCore.getDb().isOverlayAboveInput(mNode.getPackageNameS());

    //ensure z-order
    if (getParent() != null) {
        ViewGroup vg = (ViewGroup) getParent();
        if (vg.indexOfChild(this) < vg.getChildCount() - 1) {
            vg.removeView(this);
            vg.addView(this);
        }
    }

    //bounds in parent reported by the node are only good for getting the nodes dimensions, top/left are alyways 0!
    int nodeWidth = node.getBoundsInParent().width() + mRightDrawableWidth;
    int nodeHeight = node.getBoundsInParent().height();

    Rect boundsInScreen = node.getBoundsInScreen();
    Rect boundsInParent = new Rect(boundsInScreen); //TODO pool
    boundsInParent.offset(-parentBoundsInScreen.left, -parentBoundsInScreen.top); //calculate the real bounds in parent.

    mVisibleHeight = boundsInScreen.height();

    if (boundsInScreen.height() < node.getBoundsInParent().height()) {
        //node seems to be cut off
        if (boundsInParent.top == 0) {
            //cut off at the top
            boundsInParent.offset(0, -(node.getBoundsInParent().height() - boundsInScreen.height()));
        }

    }
    boolean changed = false;
    changed = changed | (in.x != boundsInParent.left);
    in.x = boundsInParent.left;


    if (!above) {
        changed = changed | (in.y != boundsInParent.top);
        in.y = boundsInParent.top;
    } else {
        changed = changed | (in.y != boundsInParent.top - nodeHeight);
        in.y = boundsInParent.top - getHeight();

        if (in.y < 0) {
            //parent doesn't have enough space, try to increase size of parent
            ViewParent vp = getParent();
            if (vp != null && vp instanceof NodeGroupLayout) {
                NodeGroupLayout parent = (NodeGroupLayout) vp;
                parent.makeSpaceAbove(-in.y);
                in.y = 0;
            }
        }

    }

    changed = changed | (in.width != nodeWidth);
    in.width = nodeWidth;

    changed = changed | (in.height != nodeHeight);
    in.height = nodeHeight;

    if (above || mCore.getDb().isVoverflow(mNode.getPackageNameS())) {
        in.height = AbsoluteLayout.LayoutParams.WRAP_CONTENT;
    }

    return changed;
}
 
Example 16
Source File: NodeTextView.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
public NodeTextView(Core core, Tree.TreeNode node, Rect parentBoundsInScreen, OverlayDecryptView overlayDecryptView, CryptoHandlerFacade cryptoHandlerFacade) {
    super(core.getCtx());
    mCore = core;
    mNode = node;
    mCryptoHandlerFacade = cryptoHandlerFacade;
    mOverlayDecryptView = overlayDecryptView;

    //--------------------- update layout / dimensions

    AbsoluteLayout.LayoutParams params = new AbsoluteLayout.LayoutParams(0, 0, 0, 0);
    calcLayoutParams(params, node, parentBoundsInScreen);
    setLayoutParams(params);


    //----------------------- update contents


    mBgShape = new GradientDrawable();
    setBackground(mBgShape);

    overlayDecryptView.applyDesign(this);

    readNodeInfo(true);
}
 
Example 17
Source File: NodeGroupLayout.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
@Override
    public void update(Tree.TreeNode node, Rect parentBoundsInScreen) {
        mUnused = false;
        mNode.recycle(false);
        mNode = node;

        //--------------------- update layout / dimensions

        ViewGroup.LayoutParams pp = getLayoutParams();

        if (pp instanceof AbsoluteLayout.LayoutParams) {
            AbsoluteLayout.LayoutParams params = (AbsoluteLayout.LayoutParams) pp;
            boolean changed = calcLayoutParams(params, node, parentBoundsInScreen);
            if (changed) {
                setLayoutParams(params);
            }
        } else {
            Ln.w("Hoooh?  LayoutParams are not from AbsoluteLayout??");
//            //how can this happen?
//            boolean changed = calcLayoutParamsRoot(pp, node, parentBoundsInScreen);
//            if (changed) {
//                setLayoutParams(pp);
//            }
        }
        //--------------------- update child views

        //mark alle existing vchild views as dirty
        int viewChildChount = getChildCount();
        for (int i = 0; i < viewChildChount; i++) {
            ((NodeView) getChildAt(i)).setUnused();
        }

        int cc = node.getChildCount();
        for (int i = 0; i < cc; i++) {
            boolean foundExisting = false;
            Tree.TreeNode nodeChild = node.getChildAt(i);

            for (int k = 0; k < getChildCount(); k++) {
                NodeView viewChild = ((NodeView) getChildAt(k));

                if (viewChild != null && viewChild.getNodeKey() == nodeChild.getKey() && viewChild.matchesNodeType(nodeChild)) {
                    viewChild.update(nodeChild, node.getBoundsInScreen());
                    foundExisting = true;
                    break;
                }
            }

            if (!foundExisting) {

                View childView = null;
                if (nodeChild.isTextNode()) {
                    childView = new NodeTextView(mCore, nodeChild, node.getBoundsInScreen(), mOverlayDecryptView, mCryptoHandlerFacade);
                } else {
                    childView = new NodeGroupLayout(mCore, nodeChild, node.getBoundsInScreen(), mOverlayDecryptView, mCryptoHandlerFacade);
                }
                addView(childView);
            }
        }

        //remove all dirty views
        for (int i = viewChildChount - 1; i >= 0; i--) {
            NodeView child = ((NodeView) getChildAt(i));
            if (child.isUnused()) {
                child.recycle();
                removeViewAt(i);
            }
        }
    }