本文整理了Java中android.widget.ImageView.setScaleType()
方法的一些代码示例,展示了ImageView.setScaleType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ImageView.setScaleType()
方法的具体详情如下:
包路径:android.widget.ImageView
类名称:ImageView
方法名:setScaleType
暂无
代码示例来源:origin: scwang90/SmartRefreshLayout
@Override
public void displayImage(Context context, Object path, ImageView imageView) {
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageResource((Integer)path);
}
}
代码示例来源:origin: stackoverflow.com
ImageView mImageView= (ImageView)findViewById(R.id.imageview_id);
Bitmap original = BitmapFactory.decodeResource(getResources(),R.drawable.content_image);
Bitmap mask = BitmapFactory.decodeResource(getResources(),R.drawable.mask);
Bitmap result = Bitmap.createBitmap(mask.getWidth(), mask.getHeight(), Config.ARGB_8888);
Canvas mCanvas = new Canvas(result);
Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
mCanvas.drawBitmap(original, 0, 0, null);
mCanvas.drawBitmap(mask, 0, 0, paint);
paint.setXfermode(null);
mImageView.setImageBitmap(result);
mImageView.setScaleType(ScaleType.CENTER);
mImageView.setBackgroundResource(R.drawable.background_frame);
代码示例来源:origin: stackoverflow.com
public class FullScreenImage extends Activity
{
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.full_image);
Intent intent = getIntent();
long imageId = intent.getExtras().get(thisClassName.class.getName());
ImageView imageView = (ImageView)v.findViewById(R.id.fullImage);
imageView.setLayoutParams( new ViewGroup.LayoutParams(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT));
imageView.setImageResource(imageId);
imageView.setScaleType(ImageView.ScaleType.FIT_XY);
}
}
代码示例来源:origin: dinuscxj/RecyclerRefreshLayout
public DefaultTipsHelper(RecyclerFragment<?> fragment) {
mFragment = fragment;
mRecyclerView = fragment.getRecyclerView();
mRefreshLayout = fragment.getRecyclerRefreshLayout();
mLoadingView = new ImageView(fragment.getActivity());
mLoadingView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
mLoadingView.setImageResource(R.drawable.spinner);
mLoadingView.setPadding(0, (int) DensityUtil.dip2px(mFragment.getActivity(), 10),
0, (int) DensityUtil.dip2px(mFragment.getActivity(), 10));
mLoadingView.setLayoutParams(new RecyclerView.LayoutParams(
RecyclerRefreshLayout.LayoutParams.MATCH_PARENT,
(int) DensityUtil.dip2px(fragment.getActivity(), 40)));
}
代码示例来源:origin: stackoverflow.com
ImageView imageView = new ImageView(context);
int padding = 10;
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.MATRIX);
imageView.setImageResource(R.drawable.ic_launcher);
container.addView(imageView, 0);
return container;
代码示例来源:origin: stackoverflow.com
imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
setContentView(imageView);
imageView.setScaleType(ImageView.ScaleType.CENTER);
imageView.setImageBitmap(bitmap);
代码示例来源:origin: Ramotion/cardslider-android
@Override
public View makeView() {
final ImageView imageView = new ImageView(MainActivity.this);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
final LayoutParams lp = new ImageSwitcher.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
imageView.setLayoutParams(lp);
return imageView;
}
}
代码示例来源:origin: pili-engineering/PLDroidShortVideo
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) {
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(300, 300));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
imageView.setTag(position);
imageView.setImageDrawable(null);
imageView.setBackgroundColor(getResources().getColor(mSelectedFrameIndex.contains(position) ? R.color.colorAccent : R.color.white));
Bitmap cached = mBitmapCache.get(position);
if (cached != null) {
imageView.setImageBitmap(cached);
} else {
LoadFrameTask task = mOngoingTasks.get(position);
if (task != null && task.getStatus() == AsyncTask.Status.RUNNING) {
task.cancel(true);
}
task = new LoadFrameTask(position, imageView);
mOngoingTasks.put(position, task);
task.execute();
}
return imageView;
}
}
代码示例来源:origin: stackoverflow.com
public View getView(int arg0, View arg1, ViewGroup arg2) {
if(arg1!=null)
{
ImageView imv = new ImageView(cont);
imv.setLayoutParams(new GridView.LayoutParams(40,40));
imv.setScaleType(ScaleType.CENTER_CROP);
imv.setPadding(0,0,0,0);
arg1 = imv;
}
arg1.setTag(arg0);
return arg1;
}
代码示例来源:origin: amahi/android
private void setUpAudioMetadata(String audioTitle, String audioSubtitle, Bitmap albumArt) {
audioTitleText.setText(audioTitle);
audioSubtitleText.setText(audioSubtitle);
if (albumArt != null) {
audioAlbumArt.setImageBitmap(albumArt);
audioAlbumArt.setScaleType(ImageView.ScaleType.CENTER_CROP);
} else {
audioAlbumArt.setImageResource(R.drawable.default_audiotrack);
audioAlbumArt.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
}
}
代码示例来源:origin: stackoverflow.com
LinearLayout layout = (LinearLayout) findViewById(R.id.linear);
for (int i = 0; i < 10; i++) {
ImageView imageView = new ImageView(this);
imageView.setId(i);
imageView.setPadding(2, 2, 2, 2);
imageView.setImageBitmap(BitmapFactory.decodeResource(
getResources(), R.drawable.ic_launcher));
imageView.setScaleType(ScaleType.FIT_XY);
layout.addView(imageView);
}
代码示例来源:origin: tianshaojie/AndroidFine
mArrowImageView.setPadding(padding, padding, padding, padding);
addView(mArrowImageView);
mArrowImageView.setScaleType(ScaleType.MATRIX);
Matrix matrix = new Matrix();
matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
代码示例来源:origin: stackoverflow.com
//assuming your layout is in a LinearLayout as its root
LinearLayout layout = (LinearLayout)findViewById(R.id.rootlayout);
ImageView image = new ImageView(this);
image.setImageResource(R.drawable.image);
int newHeight = getWindowManager().getDefaultDisplay().getHeight() / 2;
int orgWidth = image.getDrawable().getIntrinsicWidth();
int orgHeight = image.getDrawable().getIntrinsicHeight();
//double check my math, this should be right, though
int newWidth = Math.floor((orgWidth * newHeight) / orgHeight);
//Use RelativeLayout.LayoutParams if your parent is a RelativeLayout
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
newWidth, newHeight);
image.setLayoutParams(params);
image.setScaleType(ImageView.ScaleType.CENTER_CROP);
layout.addView(image);
代码示例来源:origin: stackoverflow.com
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView = new ImageView(mContext);
imageView.setImageResource(mThumbIds[position]);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setLayoutParams(new GridView.LayoutParams(
(int) mContext.getResources().getDimension(R.dimen.width),
(int) mContext.getResources().getDimension(R.dimen.height)));
imageView.setPadding(5, 5, 5, 5);
return imageView;
}
代码示例来源:origin: CarGuo/GSYVideoPlayer
public void onBind(final int position, VideoModel videoModel) {
//增加封面
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setImageResource(R.mipmap.xxx1);
smallVideoHelper.addVideoPlayer(position, imageView, TAG, listItemContainer, listItemBtn);
listItemBtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
smallVideoHelper.setPlayPositionAndTag(position, TAG);
getRecyclerBaseAdapter().notifyDataSetChanged();
//listVideoUtil.setLoop(true);
String url;
if (position % 2 == 0) {
url = "https://res.exexm.com/cw_145225549855002";
} else {
url = "http://wdquan-space.b0.upaiyun.com/VIDEO/2018/11/22/ae0645396048_hls_time10.m3u8";
}
//listVideoUtil.setCachePath(new File(FileUtils.getPath()));
gsySmallVideoHelperBuilder.setVideoTitle("title " + position).setUrl(url);
smallVideoHelper.startPlay();
//必须在startPlay之后设置才能生效
//listVideoUtil.getGsyVideoPlayer().getTitleTextView().setVisibility(View.VISIBLE);
}
});
}
代码示例来源:origin: Zomato/AndroidPhotoFilters
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, final int i) {
final ThumbnailItem thumbnailItem = dataSet.get(i);
Log.v(TAG, "On Bind View Called");
ThumbnailsViewHolder thumbnailsViewHolder = (ThumbnailsViewHolder) holder;
thumbnailsViewHolder.thumbnail.setImageBitmap(thumbnailItem.image);
thumbnailsViewHolder.thumbnail.setScaleType(ImageView.ScaleType.FIT_START);
setAnimation(thumbnailsViewHolder.thumbnail, i);
thumbnailsViewHolder.thumbnail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (lastPosition != i) {
thumbnailCallback.onThumbnailClick(thumbnailItem.filter);
lastPosition = i;
}
}
});
}
代码示例来源:origin: stackoverflow.com
public Object instantiateItem(ViewGroup container, int position) {
RelativeLayout v0 = (RelativeLayout ) inflater.inflate (R.layout.one_of_my_page_layouts, null);
ImageView imageView = vo.findViewById(R.id.photo_thumb);
int padding = 10;
imageView.setPadding(padding, padding, padding, padding);
imageView.setScaleType(ImageView.ScaleType.MATRIX);
imageView.setImageResource(GalImages[position]);
container.addView(v0, 0);
return v0;
}
代码示例来源:origin: stackoverflow.com
public View getView(int position, View convertView, ViewGroup parent) {
ImageView i = new ImageView(context);
// Move cursor to current position
cursor.moveToPosition(position);
// Get the current value for the requested column
int imageID = cursor.getInt(columnIndex);
// obtain the image URI
Uri uri = Uri.withAppendedPath( MediaStore.Images.Media.EXTERNAL_CONTENT_URI, Integer.toString(imageID) );
String url = uri.toString();
// Set the content of the image based on the image URI
int originalImageId = Integer.parseInt(url.substring(url.lastIndexOf("/") + 1, url.length()));
Bitmap b = MediaStore.Images.Thumbnails.getThumbnail(getContentResolver(),
originalImageId, MediaStore.Images.Thumbnails.MINI_KIND, null);
i.setImageBitmap(b);
i.setLayoutParams(new Gallery.LayoutParams(150, 100));
i.setScaleType(ImageView.ScaleType.FIT_XY);
i.setBackgroundResource(mGalleryItemBackground);
return i;
}
代码示例来源:origin: Ramotion/expanding-collection-android
public View makeView() {
ImageView myView = new ImageView(context);
myView.setScaleType(ImageView.ScaleType.CENTER_CROP);
myView.setLayoutParams(new FrameLayout.LayoutParams(bgImageWidth, FrameLayout.LayoutParams.MATCH_PARENT));
myView.setTranslationX(-bgImageGap);
return myView;
}
});
代码示例来源:origin: stackoverflow.com
ImageView imageView = new ImageView(this);
imageView.setImageBitmap(bmp);
imageView.setLayoutParams(params);
imageView.setBackgroundResource(R.drawable.main_header_selector);
imageView.setPadding(2, 2, 2, 2);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); // <- set the scale
imageView.setCropToPadding(true); // <- requires API 16 or more
内容来源于网络,如有侵权,请联系作者删除!