当前位置: 首页>>代码示例>>Java>>正文


Java ImageView.getMeasuredWidth方法代码示例

本文整理汇总了Java中android.widget.ImageView.getMeasuredWidth方法的典型用法代码示例。如果您正苦于以下问题:Java ImageView.getMeasuredWidth方法的具体用法?Java ImageView.getMeasuredWidth怎么用?Java ImageView.getMeasuredWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.getMeasuredWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: inflateDialogView

import android.widget.ImageView; //导入方法依赖的package包/类
@Override
    protected View inflateDialogView(FrameLayout dialogRootLayout, LayoutInflater inflater) {
        LinearLayout containLayout = new LinearLayout(mActivity);
        containLayout.setOrientation(LinearLayout.VERTICAL);

        if (canCanceledOnOutside()) {
            containLayout.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finishDialog();
                }
            });
        }

        ImageView triangleView = new ImageView(mActivity);
        triangleView.setImageResource(R.drawable.base_trigon);
        if (showTriangle) {
            triangleView.measure(View.MeasureSpec.makeMeasureSpec(1 << 30 - 1, View.MeasureSpec.AT_MOST),
                    View.MeasureSpec.makeMeasureSpec(1 << 30 - 1, View.MeasureSpec.AT_MOST));
        }

        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-1, -2);
        LinearLayout.LayoutParams triangleParams = new LinearLayout.LayoutParams(-2, -2);

//        final int[] drawingLocation = mTmpDrawingLocation;
//        anchorView.getLocationInWindow(drawingLocation);

        final Rect displayFrame = new Rect();
        anchorView.getWindowVisibleDisplayFrame(displayFrame);

        final int[] screenLocation = mTmpScreenLocation;
        anchorView.getLocationOnScreen(screenLocation);

        int anchorWidth = anchorView.getMeasuredWidth();
        int anchorHeight = anchorView.getMeasuredHeight();

        if (screenLocation[0] + anchorWidth / 2 < displayFrame.width() / 2) {
            //左半屏
            triangleParams.gravity = Gravity.START;
            triangleParams.leftMargin = screenLocation[0] + anchorWidth / 2 - triangleView.getMeasuredWidth() / 2;
        } else {
            //右半屏
            triangleParams.gravity = Gravity.END;
            triangleParams.rightMargin = displayFrame.right - screenLocation[0] - anchorWidth / 2 - triangleView.getMeasuredWidth() / 2;
        }

        if (screenLocation[1] + anchorHeight / 2 < displayFrame.height() / 2) {
            //在屏幕上半部
            params.topMargin = screenLocation[1] + anchorHeight + offsetY;
            if (showTriangle) {
                containLayout.addView(triangleView, triangleParams);
            }
            LayoutInflater.from(mActivity).inflate(layoutId, containLayout);
            gravity = Gravity.TOP;
        } else {
            //在屏幕下半部
            LayoutInflater.from(mActivity).inflate(layoutId, containLayout);
            if (showTriangle) {
                triangleView.setRotation(180);
                containLayout.addView(triangleView, triangleParams);
            }
            params.bottomMargin = displayFrame.bottom - screenLocation[1] + offsetY;
            params.gravity = Gravity.BOTTOM;
            gravity = Gravity.BOTTOM;
        }

        dialogRootLayout.addView(containLayout, params);
        resetDialogGravity();

        if (mOnInitWindow != null) {
            mOnInitWindow.onInitWindow(this, new RBaseViewHolder(containLayout));
        }
        return containLayout;
    }
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:75,代码来源:UIWindow.java


注:本文中的android.widget.ImageView.getMeasuredWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。