本文整理了Java中android.widget.ImageView.layout()
方法的一些代码示例,展示了ImageView.layout()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.layout()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:layout
暂无
代码示例来源:origin: GitLqr/LQRWeChat
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
LayoutParams contentParams = (LayoutParams) mContentView.getLayoutParams();
mContentView.layout(contentParams.left, currentTop,
contentParams.left + sWidth, currentTop + sHeight);
mRainbowView.layout(rainbowRadius, rainbowTop,
rainbowRadius * 2, rainbowTop + rainbowRadius);
}
代码示例来源:origin: andkulikov/Transitions-Everywhere
int heightSpec = View.MeasureSpec.makeMeasureSpec(bottom - top, View.MeasureSpec.EXACTLY);
copy.measure(widthSpec, heightSpec);
copy.layout(left, top, right, bottom);
return copy;
代码示例来源:origin: wangdan/AisenWeiBo
childView.layout(imgRect.left, imgRect.top, imgRect.right, imgRect.bottom);
代码示例来源:origin: jeasonlzy/NineGridView
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (mImageInfo == null) return;
int childrenCount = mImageInfo.size();
for (int i = 0; i < childrenCount; i++) {
ImageView childrenView = (ImageView) getChildAt(i);
int rowNum = i / columnCount;
int columnNum = i % columnCount;
int left = (gridWidth + gridSpacing) * columnNum + getPaddingLeft();
int top = (gridHeight + gridSpacing) * rowNum + getPaddingTop();
int right = left + gridWidth;
int bottom = top + gridHeight;
childrenView.layout(left, top, right, bottom);
if (mImageLoader != null) {
mImageLoader.onDisplayImage(getContext(), childrenView, mImageInfo.get(i).thumbnailUrl);
}
}
}
代码示例来源: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: 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: 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: bumptech/glide
imageView.layout(0, 0, 100, 100);
doAnswer(new CallSizeReady()).when(target).getSize(isA(SizeReadyCallback.class));
代码示例来源:origin: Clans/FloatingActionButton
int imageTop = menuButtonTop + mMenuButton.getMeasuredHeight() / 2 - mImageToggle.getMeasuredHeight() / 2;
mImageToggle.layout(imageLeft, imageTop, imageLeft + mImageToggle.getMeasuredWidth(),
imageTop + mImageToggle.getMeasuredHeight());
代码示例来源:origin: wuyr/CatchPiggy
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
int currentWidth;
int currentMargin;
//5个心 水平排列
for (int i = 0; i < mItems.length; i++) {
currentWidth = i * mItemSize;
currentMargin = i * mItemMargin;
currentWidth += currentMargin;
mItems[i].layout(currentWidth, 0, currentWidth + mItemSize, mItemSize);
}
}
代码示例来源:origin: polyak01/IconSwitch
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
leftIcon.layout(iconOffset, iconTop, iconOffset + iconSize, iconBottom);
int rightIconLeft = switchWidth - iconOffset - iconSize;
rightIcon.layout(rightIconLeft, iconTop, rightIconLeft + iconSize, iconBottom);
int thumbLeft = (int) (thumbStartLeft + thumbDragDistance * thumbPosition);
thumb.layout(thumbLeft, 0, thumbLeft + thumbDiameter, switchHeight);
}
代码示例来源:origin: QDqiaodong/Reader
public void onPostExecute(Void result) {
mPatchViewSize = patchViewSize;
mPatchArea = patchArea;
mPatch.setImageBitmap(mPatchBm);
mPatch.invalidate();
//requestLayout();
// Calling requestLayout here doesn't lead to a later call to layout. No idea
// why, but apparently others have run into the problem.
mPatch.layout(mPatchArea.left, mPatchArea.top, mPatchArea.right, mPatchArea.bottom);
}
};
代码示例来源:origin: InQBarna/TableFixHeaders
private void addShadow(ImageView imageView, int l, int t, int r, int b) {
imageView.layout(l, t, r, b);
addView(imageView);
}
代码示例来源:origin: wuyr/CatchPiggy
private void layoutDropView(Item item) {
MyLayoutParams layoutParams = (MyLayoutParams) mDropView.getLayoutParams();
if (layoutParams.isDrag) {
mDropView.layout(mDropView.getLeft() + layoutParams.x, mDropView.getTop() + layoutParams.y,
mDropView.getRight() + layoutParams.x, mDropView.getBottom() + layoutParams.y);
} else {
mDropView.layout(0, 0, mDropView.getLayoutParams().width, mDropView.getLayoutParams().height);
mDropView.layout((int) item.getX() - (mDropView.getWidth() - item.getWidth()),
item.getBottom() - mDropView.getHeight(), (int) item.getX() + mDropView.getWidth(), item.getBottom());
}
}
代码示例来源:origin: huangfangyi/FanXin
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
LayoutParams contentParams = (LayoutParams) mContentView.getLayoutParams();
mContentView.layout(contentParams.left, currentTop,
contentParams.left + sWidth, currentTop + sHeight);
mRainbowView.layout(rainbowRadius, rainbowTop,
rainbowRadius * 2 , rainbowTop + rainbowRadius);
}
代码示例来源: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: rockon999/LeanbackLauncher
private void layoutPlayIndicator() {
if (this.mPlayingIndicator != null && this.mPauseImage != null) {
int endPadding = (int) getResources().getDimension(R.dimen.leanback_card_now_playing_padding_end);
int bottomPadding = (int) getResources().getDimension(R.dimen.leanback_card_now_playing_padding_bottom);
int left = getMeasuredWidth() - endPadding;
int right = getMeasuredWidth() - endPadding;
int top = this.mImageHeight - bottomPadding;
int bottom = this.mImageHeight - bottomPadding;
this.mPauseImage.layout(left - this.mPauseImage.getMeasuredWidth(), top - this.mPauseImage.getMeasuredHeight(), right, bottom);
this.mPlayingIndicator.layout(left - this.mPlayingIndicator.getMeasuredWidth(), top - this.mPlayingIndicator.getMeasuredHeight(), right, bottom);
}
}
代码示例来源:origin: fanbaoying/FBYIDCardRecognition-Android
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
displayView.layout(left, 0, right, bottom - top);
maskView.layout(left, 0, right, bottom - top);
int hintViewWidth = DimensionUtil.dpToPx(250);
int hintViewHeight = DimensionUtil.dpToPx(25);
int hintViewLeft = (getWidth() - hintViewWidth) / 2;
int hintViewTop = maskView.getFrameRect().bottom + DimensionUtil.dpToPx(16);
hintViewTextWrapper.layout(hintViewLeft, hintViewTop,
hintViewLeft + hintViewWidth, hintViewTop + hintViewHeight);
hintView.layout(hintViewLeft, hintViewTop,
hintViewLeft + hintViewWidth, hintViewTop + hintViewHeight);
}
代码示例来源: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());
}
内容来源于网络,如有侵权,请联系作者删除!