本文整理匯總了Java中android.widget.ImageView.setMaxWidth方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setMaxWidth方法的具體用法?Java ImageView.setMaxWidth怎麽用?Java ImageView.setMaxWidth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setMaxWidth方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createOptionIcon
import android.widget.ImageView; //導入方法依賴的package包/類
private View createOptionIcon(GridLayout parent, int rowIndex, boolean editIconExists) {
// The icon has a pre-defined width.
ImageView optionIcon = new ImageView(parent.getContext());
optionIcon.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
optionIcon.setBackgroundResource(R.drawable.payments_ui_logo_bg);
optionIcon.setImageDrawable(mOption.getDrawableIcon());
optionIcon.setMaxWidth(mIconMaxWidth);
// Place option icon at column three if no edit icon.
int columnStart = editIconExists ? 2 : 3;
GridLayout.LayoutParams iconParams = new GridLayout.LayoutParams(
GridLayout.spec(rowIndex, 1, GridLayout.CENTER),
GridLayout.spec(columnStart, 1));
iconParams.topMargin = mVerticalMargin;
parent.addView(optionIcon, iconParams);
optionIcon.setOnClickListener(OptionSection.this);
return optionIcon;
}
示例2: addImage
import android.widget.ImageView; //導入方法依賴的package包/類
public void addImage(StorageReference storageRef, String filePath, String storyId) {
storyId += "-photo";
removeStuffWithThisKey(storyId);
final ImageView imageThing = new ImageView(myContext);
int gridThingPixels = (int) myContext.getResources().getDimension(R.dimen.grid_thing);
imageThing.setMaxHeight(gridThingPixels);
imageThing.setMaxWidth(gridThingPixels);
gridContents.add(new TaggedView(imageThing, storyId));
this.notifyDataSetChanged();
// and a photo (up to 10mb)
Task<byte[]> imageDownloadTask = storageRef.child(filePath).getBytes(100 * 1024 * 1024);
imageDownloadTask.addOnCompleteListener(new OnCompleteListener<byte[]>() {
@Override
public void onComplete(@NonNull Task<byte[]> task) {
byte[] imageBytes = task.getResult();
Bitmap imageBitmap = BitmapFactory.decodeByteArray(imageBytes, 0, imageBytes.length);
imageThing.setImageBitmap(imageBitmap);
StoryAdapter.this.notifyDataSetChanged();
}
});
}