本文整理了Java中android.widget.ImageView.measure()
方法的一些代码示例,展示了ImageView.measure()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.measure()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:measure
暂无
代码示例来源:origin: andkulikov/Transitions-Everywhere
copy.measure(widthSpec, heightSpec);
copy.layout(left, top, right, bottom);
return copy;
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Before
public void setUp() throws Exception {
mActivity = new Activity();
// Make and set view with some prelim values to test
mView = new TestImageView(mActivity);
mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY));
mImageAware = new ImageViewAware(mView);
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
/**
* This will make sure the view falls back to the ViewParams/Max/Or Config if wrap content so that it is never
* shrunk to the first image size. In this case it falls back to the config size
*
* @throws Exception
*/
@Test
public void testGetImageSizeScaleTo_dontUseImageActualSizeWithWrapContent() throws Exception {
//Set it to wrap content so that it will fall back to
mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY));
// We layout the view to give it a width and height
mView.layout(0, 0, 200, 200);
ImageSize expected = new ImageSize(500, 500);
ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500));
Assertions.assertThat(result).isNotNull().isEqualsToByComparingFields(expected);
}
代码示例来源:origin: bumptech/glide
/**
* 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);
}
});
}
代码示例来源:origin: bumptech/glide
@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()));
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Test
public void testGetImageSizeScaleTo_useImageActualSize() throws Exception {
// We layout the view to give it a width and height
mView.measure(View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY));
mView.layout(0, 0, 200, 200);
ImageSize expected = new ImageSize(200, 200);
ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(590, 590));
Assertions.assertThat(result).isNotNull();
Assertions.assertThat(result.getWidth()).isEqualTo(expected.getWidth());
Assertions.assertThat(result.getHeight()).isEqualTo(expected.getHeight());
}
代码示例来源:origin: rockon999/LeanbackLauncher
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
this.mPlayingIndicator.measure(widthMeasureSpec, heightMeasureSpec);
this.mPauseImage.measure(0, 0);
}
代码示例来源:origin: polyak01/IconSwitch
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int overshootPadding = Math.round(thumbDiameter * 0.1f);
int width = getSize(widthMeasureSpec, switchWidth + overshootPadding * 2);
int height = getSize(heightMeasureSpec, switchHeight);
int thumbSpec = MeasureSpec.makeMeasureSpec(switchHeight, MeasureSpec.EXACTLY);
thumb.measure(thumbSpec, thumbSpec);
int iconSpec = MeasureSpec.makeMeasureSpec(iconSize, MeasureSpec.EXACTLY);
leftIcon.measure(iconSpec, iconSpec);
rightIcon.measure(iconSpec, iconSpec);
background.init(iconSize, width, height);
translationX = (width / 2) - (switchWidth / 2);
translationY = (height / 2) - (switchHeight / 2);
setMeasuredDimension(width, height);
}
代码示例来源:origin: stackoverflow.com
ImageView myimage = (ImageView)findViewById(R.id.myimage);
Animation animation = new TranslateAnimation(100, 200, 300, 400);
animation.setDuration(1000);
myimage.startAnimation(animation);
animation.setRepeatCount(Animation.INFINITE);
int[] firstPosition = new int[2];
myimage.measure(View.MeasureSpec.EXACTLY, View.MeasureSpec.EXACTLY);
myimage.getLocationOnScreen(firstPosition);
int r = myimage.getMeasuredWidth() + firstPosition[1];
int rr = myimage.getMeasuredWidth() + firstPosition[0];
代码示例来源:origin: L4Digital/FastScroll
private void updateViewHeights() {
int measureSpec = MeasureSpec.makeMeasureSpec(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
bubbleView.measure(measureSpec, measureSpec);
bubbleHeight = bubbleView.getMeasuredHeight();
handleView.measure(measureSpec, measureSpec);
handleHeight = handleView.getMeasuredHeight();
}
代码示例来源:origin: SIdQi/PullRefreshLayout
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
ensureTarget();
if (mTarget == null)
return;
widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth() - getPaddingRight() - getPaddingLeft(), MeasureSpec.EXACTLY);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY);
mTarget.measure(widthMeasureSpec, heightMeasureSpec);
mRefreshView.measure(widthMeasureSpec, heightMeasureSpec);
mLoadView.measure(widthMeasureSpec, heightMeasureSpec);
}
代码示例来源:origin: Cutta/LoadingImagesAnimation
private void setViews() {
if (imagesArrayId == DEFAULT_RESOURCE_ID) {
Log.e(TAG, "Images must be initialized before it can be used. You can use in XML like this: (app:imagesArray=app:imagesArray=\"@array/loading_car_images\") ");
return;
}
firstImage = findViewById(R.id.first_image);
secondImage = findViewById(R.id.second_image);
separatorLayout = findViewById(R.id.separator_layout);
View divider = findViewById(R.id.divider);
firstImage.setImageResource(imagesArray.getResourceId(getImageIndex(), DEFAULT_RESOURCE_ID));
secondImage.setImageResource(imagesArray.getResourceId(getImageIndex(), DEFAULT_RESOURCE_ID));
firstImage.setBackgroundColor(backgroundColor);
secondImage.setBackgroundColor(backgroundColor);
divider.setBackgroundColor(dividerColor);
firstImage.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED);
maxWidth = firstImage.getMeasuredWidth();
}
代码示例来源:origin: TellH/Android_PullToRefreshLibrary_Collection
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
ensureTarget();
if (mTarget == null)
return;
widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth() - getPaddingRight() - getPaddingLeft(), MeasureSpec.EXACTLY);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight() - getPaddingTop() - getPaddingBottom(), MeasureSpec.EXACTLY);
mTarget.measure(widthMeasureSpec, heightMeasureSpec);
mRefreshView.measure(widthMeasureSpec, heightMeasureSpec);
}
代码示例来源:origin: Ilya-Gh/Typewriter
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
View targetView = getTargetView();
if (targetView != null) {
widthMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredWidth() - getPaddingLeft() - getPaddingRight(), MeasureSpec.EXACTLY);
heightMeasureSpec = MeasureSpec.makeMeasureSpec(getMeasuredHeight() - getPaddingBottom() - getPaddingTop(), MeasureSpec.EXACTLY);
targetView.measure(widthMeasureSpec, heightMeasureSpec);
refreshView.measure(widthMeasureSpec, heightMeasureSpec);
}
}
代码示例来源:origin: stackoverflow.com
public class Something extends Activity {
ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_something);
imageView = (ImageView) findViewById(R.id.yourImage);
getDimensions();
}
private void getDimensions() {
imageView.measure(imageView.getMeasuredWidth(),
imageView.getMeasuredHeight());
int Width = getMeasuredWidth();
int Height = getMeasuredHeight();
Toast.makeText(this, "width: " + Width + " height: " + Height,
Toast.LENGTH_SHORT).show();
}
}
代码示例来源:origin: stackoverflow.com
final ImageView tempImageView = new ImageView(getActivity());
final Bitmap tmp = BitmapFactory.decodeFile(LayoutParams.WRAP_CONTENT);
tempImageView.setImageBitmap(tmp);
tempImageView.setDrawingCacheEnabled(true);
// resize and create canvas
tempImageView.measure(MeasureSpec.makeMeasureSpec(256, MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(256, MeasureSpec.EXACTLY));
tempImageView.layout(0, 0, tempImageView.getMeasuredWidth(), tempImageView.getMeasuredHeight());
tempImageView.buildDrawingCache(true);
final Bitmap resized_bm = Bitmap.createBitmap(tempImageView.getDrawingCache());
tempImageView.setDrawingCacheEnabled(false);
代码示例来源:origin: jiangqqlmj/Android-Universal-Image-Loader-Modify
@Before
public void setUp() throws Exception {
mActivity = new Activity();
// Make and set view with some prelim values to test
mView = new TestImageView(mActivity);
mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY));
mImageAware = new ImageViewAware(mView);
}
代码示例来源:origin: jiangqqlmj/Android-Universal-Image-Loader-Modify
/**
* This will make sure the view falls back to the ViewParams/Max/Or Config if wrap content so that it is never
* shrunk to the first image size. In this case it falls back to the config size
*
* @throws Exception
*/
@Test
public void testGetImageSizeScaleTo_dontUseImageActualSizeWithWrapContent() throws Exception {
//Set it to wrap content so that it will fall back to
mView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
mView.measure(View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(250, View.MeasureSpec.EXACTLY));
// We layout the view to give it a width and height
mView.layout(0, 0, 200, 200);
ImageSize expected = new ImageSize(500, 500);
ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(500, 500));
Assertions.assertThat(result).isNotNull().isEqualsToByComparingFields(expected);
}
代码示例来源:origin: jiangqqlmj/Android-Universal-Image-Loader-Modify
@Test
public void testGetImageSizeScaleTo_useImageActualSize() throws Exception {
// We layout the view to give it a width and height
mView.measure(View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY), View.MeasureSpec.makeMeasureSpec(200, View.MeasureSpec.EXACTLY));
mView.layout(0, 0, 200, 200);
ImageSize expected = new ImageSize(200, 200);
ImageSize result = ImageSizeUtils.defineTargetSizeForView(mImageAware, new ImageSize(590, 590));
Assertions.assertThat(result).isNotNull();
Assertions.assertThat(result.getWidth()).isEqualTo(expected.getWidth());
Assertions.assertThat(result.getHeight()).isEqualTo(expected.getHeight());
}
代码示例来源:origin: ronaldsmartin/Material-ViewPagerIndicator
endDot.measure(childWidthSpec, childHeightSpec);
endPathSegment.measure(childWidthSpec, childHeightSpec);
centerSegment.measure(childWidthSpec, childHeightSpec);
内容来源于网络,如有侵权,请联系作者删除!