android.widget.AbsoluteLayout Java Examples

The following examples show how to use android.widget.AbsoluteLayout. 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: 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 #6
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 #7
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 #8
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 #9
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 #10
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 #11
Source File: RedBoundPopupWindow.java    From fuckView with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected View onCreateView(Context context) {
    AbsoluteLayout absoluteLayout = new AbsoluteLayout(context);
    GradientDrawable gd = new GradientDrawable();
    gd.setStroke(4, Color.RED);
    absoluteLayout.setBackgroundDrawable(gd);
    return absoluteLayout;
}
 
Example #12
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 #13
Source File: OverlayInfoButtonView.java    From oversec with GNU General Public License v3.0 5 votes vote down vote up
public OverlayInfoButtonView(Core core, String encryptedText, Rect boundsInScreen, String packageName) {
    super(core, packageName);
    mEncryptedText = encryptedText;
    mBoundsInScreen = new Rect(boundsInScreen);

    mHeight = core.dipToPixels(HEIGHT_DP);
    //noinspection SuspiciousNameCombination
    mWidth = mHeight;

    updateLayoutParams();

    ContextThemeWrapper ctw = new ContextThemeWrapper(core.getCtx(), R.style.AppTheme);
    mView = (ImageButton) LayoutInflater.from(ctw)
            .inflate(R.layout.overlay_info_button, null);

    //noinspection deprecation
    addView(mView, new AbsoluteLayout.LayoutParams(mWidth, mHeight, 0, 0));

    calcPosition();

    mView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            mCore.removeOverlayDecrypt(false);
            EncryptionInfoActivity.Companion.show(getContext(), mPackageName, mEncryptedText, mView);
        }
    });
}
 
Example #14
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 #15
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 #16
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 #17
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 #18
Source File: ViewSnapshot.java    From ans-android-sdk with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("deprecation")
private void addProperties(JsonWriter j, View v) throws IOException {
    final Class<?> viewClass = v.getClass();
    boolean processable = true;
    for (final PropertyDescription desc : mProperties) {
        if (desc.targetClass.isAssignableFrom(viewClass) && null != desc.accessor) {
            final Object value = desc.accessor.applyMethod(v);

            if (processable) {
                if (!TextUtils.isEmpty(desc.name)) {
                    if ("clickable".equals(desc.name)) {
                        boolean isClickable = (Boolean) value;
                        if (!isClickable || v instanceof AbsListView || v instanceof AbsoluteLayout) {
                            processable = false;
                        }
                    } else if ("alpha".equals(desc.name)) {
                        float alpha = (Float) value;
                        // 透明度是0则不可见
                        if (alpha == 0) {
                            processable = false;
                        }
                    } else if ("hidden".equals(desc.name)) {
                        int hide = (Integer) value;
                        // hidden是0则隐藏
                        if (hide != 0) {
                            processable = false;
                        }
                    }
                }
            }
            j.name("processable").value(processable ? "1" : "0");
            if (null == value) {
                // Don't produce anything in this case
            } else if (value instanceof Number) {
                j.name(desc.name).value((Number) value);
            } else if (value instanceof Boolean) {
                j.name(desc.name).value((Boolean) value);
            } else if (value instanceof ColorStateList) {
                j.name(desc.name).value((Integer) ((ColorStateList) value).getDefaultColor());
            } else if (value instanceof Drawable) {
                final Drawable drawable = (Drawable) value;
                final Rect bounds = drawable.getBounds();
                j.name(desc.name);
                j.beginObject();
                j.name("classes");
                j.beginArray();
                Class<?> klass = drawable.getClass();
                while (klass != Object.class) {
                    j.value(klass.getCanonicalName());
                    klass = klass.getSuperclass();
                }
                j.endArray();
                j.name("dimensions");
                j.beginObject();
                j.name("left").value(bounds.left);
                j.name("right").value(bounds.right);
                j.name("top").value(bounds.top);
                j.name("bottom").value(bounds.bottom);
                j.endObject();
                if (drawable instanceof ColorDrawable) {
                    final ColorDrawable colorDrawable = (ColorDrawable) drawable;
                    j.name("color").value(colorDrawable.getColor());
                }
                j.endObject();
            } else {
                j.name(desc.name).value(value.toString());
            }
        }
    }
}
 
Example #19
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 #20
Source File: TileAnimation.java    From CanDialog with Apache License 2.0 4 votes vote down vote up
private static AbsoluteLayout createAnimLayout(FrameLayout rootLayout, Activity act) {


        AbsoluteLayout animLayout = new AbsoluteLayout(act);

        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);


        animLayout.setLayoutParams(params);

        animLayout.setBackgroundResource(android.R.color.transparent);


        rootLayout.addView(animLayout);
        return animLayout;
    }
 
Example #21
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult absoluteLayout() {
  return BaseDSL.v(AbsoluteLayout.class);
}
 
Example #22
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void absoluteLayout(Anvil.Renderable r) {
  return BaseDSL.v(AbsoluteLayout.class, r);
}
 
Example #23
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult absoluteLayout() {
  return BaseDSL.v(AbsoluteLayout.class);
}
 
Example #24
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void absoluteLayout(Anvil.Renderable r) {
  return BaseDSL.v(AbsoluteLayout.class, r);
}
 
Example #25
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);
            }
        }
    }
 
Example #26
Source File: AbsoluteLayoutAssert.java    From assertj-android with Apache License 2.0 4 votes vote down vote up
public AbsoluteLayoutAssert(AbsoluteLayout actual) {
  super(actual, AbsoluteLayoutAssert.class);
}