本文整理匯總了Java中android.widget.ImageView.layout方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.layout方法的具體用法?Java ImageView.layout怎麽用?Java ImageView.layout使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.layout方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
});
}
示例2: onLayout
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
if (null == imageInfos) {
return;
}
int childCount = imageInfos.size();
for (int i = 0; i < childCount; i++) {
int columnNum = i % columnCount;
int rowNum = i / columnCount;
ImageView imageView = (ImageView) getChildAt(i);
int left = (gridWidth + gridSpace) * columnNum + getPaddingLeft();
int top = (gridHeight + gridSpace) * rowNum + getPaddingTop();
int right = left + gridWidth;
int bottom = top + gridHeight;
imageView.layout(left, top, right, bottom);
if (null != iLoadImageView) {
iLoadImageView.displayImage(i, imageView, imageInfos.get(i).getThumbnailUrl());
}
}
}
示例3: onLayout
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void onLayout(boolean change, int l, int t, int r, int b) {
if (null == mImageInfo) {
return;
}
int childCount = mImageInfo.size();
for (int i = 0; i < childCount; 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);
}
}
}
示例4: onLayout
import android.widget.ImageView; //導入方法依賴的package包/類
@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);
if (mImageLoader != null) {
mImageLoader.onDisplayImage(getContext(), childrenView, mImageInfo.get(i).thumbnailUrl);
}
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);
}
}
示例5: layoutChildrenView
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* 布局 ImageView
*/
private void layoutChildrenView() {
if (mAdapter == null) {
return;
}
int showCount = getNeedShowCount(mAdapter.getItemCount());
for (int i = 0; i < showCount; i++) {
ImageView childrenView = (ImageView) getChildAt(i);
if (mAdapter != null) {
mAdapter.onDisplayImage(getContext(), childrenView, mAdapter.getItem(i));
}
int rowNum = i / mColumnCount;
int columnNum = i % mColumnCount;
int left = (mGridSize.w + mGap) * columnNum + getPaddingLeft();
int top = (mGridSize.h + mGap) * rowNum + getPaddingTop();
int right = left + mGridSize.w;
int bottom = top + mGridSize.h;
childrenView.layout(left, top, right, bottom);
}
}
示例6: setUp
import android.widget.ImageView; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
Glide.tearDown();
RobolectricPackageManager pm = RuntimeEnvironment.getRobolectricPackageManager();
ApplicationInfo info =
pm.getApplicationInfo(RuntimeEnvironment.application.getPackageName(), 0);
info.metaData = new Bundle();
info.metaData.putString(SetupModule.class.getName(), "GlideModule");
// Ensure that target's size ready callback will be called synchronously.
target = mock(Target.class);
imageView = new ImageView(RuntimeEnvironment.application);
imageView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
imageView.layout(0, 0, 100, 100);
doAnswer(new CallSizeReady()).when(target).getSize(isA(SizeReadyCallback.class));
Handler bgHandler = mock(Handler.class);
when(bgHandler.post(isA(Runnable.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
Runnable runnable = (Runnable) invocation.getArguments()[0];
runnable.run();
return true;
}
});
Lifecycle lifecycle = mock(Lifecycle.class);
RequestManagerTreeNode treeNode = mock(RequestManagerTreeNode.class);
requestManager = new RequestManager(Glide.get(getContext()), lifecycle, treeNode);
requestManager.resumeRequests();
}
示例7: 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()));
}
示例8: layoutChildView
import android.widget.ImageView; //導入方法依賴的package包/類
private void layoutChildView() {
int childrenCount = listData.size();
int singleWidth = (totalWidth - gap * (3 - 1)) / 3;
int singleHeight = singleWidth;
//根據子view數量確定高度
ViewGroup.LayoutParams params = getLayoutParams();
params.height = singleHeight * rows + gap * (rows - 1);
setLayoutParams(params);
for (int i = 0; i < childrenCount; i++) {
ImageView childrenView = (ImageView) getChildAt(i);
final String url = listData.get(i);
final int viewPosition = i;
childrenView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent intent= new Intent(mContext.getApplicationContext(), ScanPhotoAcitivity.class);
intent.putExtra("url",url);
intent.putExtra("position", viewPosition+"");
intent.putStringArrayListExtra("imagelist", mImageList);
mContext.startActivity(intent);
}
});
Picasso.with(getContext()).load(url).placeholder(R.mipmap.loading).error(R.mipmap.loading) .into(childrenView);
int[] position = findPosition(i);
int left = (singleWidth + gap) * position[1];
int top = (singleHeight + gap) * position[0];
int right = left + singleWidth;
int bottom = top + singleHeight;
childrenView.layout(left, top, right, bottom);
}
}
示例9: layoutImage
import android.widget.ImageView; //導入方法依賴的package包/類
void layoutImage(int i, int left, int top, int right, int bottom) {
final ImageView view = imageViews[i];
if (view.getLeft() == left && view.getTop() == top && view.getRight() == right
&& view.getBottom() == bottom) {
return;
}
view.layout(left, top, right, bottom);
}
示例10: setUp
import android.widget.ImageView; //導入方法依賴的package包/類
@Before
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
context = RuntimeEnvironment.application;
// Run all tasks on the main thread so they complete synchronously.
GlideExecutor executor = MockGlideExecutor.newMainThreadExecutor();
when(diskCacheFactory.build()).thenReturn(diskCache);
Glide.init(
context,
new GlideBuilder()
.setMemoryCache(memoryCache)
.setDiskCache(diskCacheFactory)
.setSourceExecutor(executor)
.setDiskCacheExecutor(executor));
Registry registry = Glide.get(context).getRegistry();
registerMockModelLoader(
GlideUrl.class, InputStream.class, new ByteArrayInputStream(new byte[0]), registry);
registerMockModelLoader(
File.class, InputStream.class, new ByteArrayInputStream(new byte[0]), registry);
registerMockModelLoader(
File.class, ParcelFileDescriptor.class, mock(ParcelFileDescriptor.class), registry);
registerMockModelLoader(File.class, ByteBuffer.class, ByteBuffer.allocate(10), registry);
// Ensure that target's size ready callback will be called synchronously.
imageView = new ImageView(context);
imageView.setLayoutParams(new ViewGroup.LayoutParams(100, 100));
imageView.layout(0, 0, 100, 100);
doAnswer(new CallSizeReady()).when(target).getSize(isA(SizeReadyCallback.class));
when(bgHandler.post(isA(Runnable.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
Runnable runnable = (Runnable) invocation.getArguments()[0];
runnable.run();
return true;
}
});
requestManager = new RequestManager(Glide.get(context), lifecycle, treeNode, context);
requestManager.resumeRequests();
}