當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageView.measure方法代碼示例

本文整理匯總了Java中android.widget.ImageView.measure方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.measure方法的具體用法?Java ImageView.measure怎麽用?Java ImageView.measure使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.measure方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: clear_withNonOwningRequestManager_afterOwningManagerIsDestroyed_doesNotThrow

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * Tests #2262.
 */
@Test
public void clear_withNonOwningRequestManager_afterOwningManagerIsDestroyed_doesNotThrow() {
  // First destroy our Fragment/Activity RequestManager.
  requestManager.onDestroy();

  final ImageView imageView = new ImageView(context);
  imageView.measure(100, 100);
  imageView.layout(0, 0, 100, 100);
  // Then start a new load with our now destroyed RequestManager.
  concurrency.loadOnMainThread(requestManager.load(ResourceIds.raw.canonical), imageView);

  // Finally clear our new load with any RequestManager other than the one we used to start it.
  concurrency.runOnMainThread(new Runnable() {
    @Override
    public void run() {
      Glide.with(context).clear(imageView);
    }
  });
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:RequestManagerTest.java

示例2: setUp

import android.widget.ImageView; //導入方法依賴的package包/類
@Before
public void setUp() {
  MockitoAnnotations.initMocks(this);
  context = InstrumentationRegistry.getTargetContext();
  imageView = new ImageView(context);
  imageView.measure(100, 100);
  imageView.layout(0, 0, 100, 100);

  // Some emulators only have a single resize thread, so waiting on a latch will block them
  // forever.
  Glide.init(context,
      new GlideBuilder().setSourceExecutor(GlideExecutor.newUnlimitedSourceExecutor()));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:RequestTest.java

示例3: 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

示例4: onMeasure

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);
    int width_AT_MOST = MeasureSpec.makeMeasureSpec(width - getPaddingStart() - getPaddingEnd(), MeasureSpec.AT_MOST);
    int height_AT_MOST = MeasureSpec.makeMeasureSpec(1 << 30 - 1, MeasureSpec.AT_MOST);
    if (mImageViews.isEmpty()) {
        if (mTextView == null) {
            setMeasuredDimension(width, getPaddingTop() + getPaddingBottom());
        } else {
            mTextView.measure(width_AT_MOST, height_AT_MOST);
            setMeasuredDimension(width, getPaddingTop() + getPaddingBottom() + mTextView.getMeasuredHeight());
        }
    } else {
        int[] imageSize = null;
        if (mConfigCallback != null) {
            imageSize = mConfigCallback.getImageSize(0);
        }
        if (imageSize == null) {
            int size = MeasureSpec.makeMeasureSpec((width - space * 2) / 3 - getPaddingLeft() + getPaddingRight(), MeasureSpec.EXACTLY);
            imageSize = new int[]{size, size};
        }

        ImageView imageView = null;
        int imageCount = mImageViews.size();
        for (int i = 0; i < imageCount; i++) {
            imageView = mImageViews.get(i);

            int widthSpec = imageSize[0];
            if (widthSpec == -1) {
                widthSpec = MeasureSpec.makeMeasureSpec(width - getPaddingStart() - getPaddingEnd(), MeasureSpec.EXACTLY);
            }

            if (imageCount == 1 && isVideo()) {
                /**視頻采用 16:9 的比例顯示*/
                int heightSpec = MeasureSpec.makeMeasureSpec((int) ((width - getPaddingStart() - getPaddingEnd()) * 9f / 16f),
                        MeasureSpec.EXACTLY);
                imageView.measure(widthSpec, heightSpec);
            } else {
                imageView.measure(widthSpec, imageSize[1]);
            }
        }

        if (imageCount == 1) {
            if (mTextView == null) {
                setMeasuredDimension(width, getPaddingTop() + getPaddingBottom() + imageView.getMeasuredHeight());
            } else {
                if (isVideo()) {
                    //視頻類型, 文本和圖片采用上下結構
                    mTextView.measure(width_AT_MOST, height_AT_MOST);
                    setMeasuredDimension(width, getPaddingTop() + getPaddingBottom() + mTextView.getMeasuredHeight() + textSpace + imageView.getMeasuredHeight());
                } else {
                    //圖片類型, 一張圖片采用左右結構
                    mTextView.measure(MeasureSpec.makeMeasureSpec(width - imageView.getMeasuredWidth() - textSpace - getPaddingLeft() - getPaddingRight(),
                            MeasureSpec.EXACTLY), heightMeasureSpec);
                    setMeasuredDimension(width, getPaddingTop() + getPaddingBottom() + Math.max(mTextView.getMeasuredHeight(), imageView.getMeasuredHeight()));
                }
            }
        } else if (imageCount > 1) {
            if (mTextView == null) {
                setMeasuredDimension(width, getPaddingTop() + getPaddingBottom() + imageView.getMeasuredHeight());
            } else {
                mTextView.measure(width_AT_MOST, height_AT_MOST);
                setMeasuredDimension(width, getPaddingTop() + getPaddingBottom() + mTextView.getMeasuredHeight() + textSpace + imageView.getMeasuredHeight());
            }
        } else {
            setMeasuredDimension(width, getPaddingTop() + getPaddingBottom());
        }
    }
}
 
開發者ID:angcyo,項目名稱:RLibrary,代碼行數:71,代碼來源:RTextImageLayout.java


注:本文中的android.widget.ImageView.measure方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。