本文整理匯總了Java中android.widget.ImageView.setScaleType方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.setScaleType方法的具體用法?Java ImageView.setScaleType怎麽用?Java ImageView.setScaleType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.widget.ImageView
的用法示例。
在下文中一共展示了ImageView.setScaleType方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ColorPicker
import android.widget.ImageView; //導入方法依賴的package包/類
public ColorPicker(Context context) {
super(context);
setWillNotDraw(false);
shadowDrawable = getResources().getDrawable(R.drawable.knob_shadow);
backgroundPaint.setColor(0xffffffff);
swatchStrokePaint.setStyle(Paint.Style.STROKE);
swatchStrokePaint.setStrokeWidth(AndroidUtilities.dp(1));
settingsButton = new ImageView(context);
settingsButton.setScaleType(ImageView.ScaleType.CENTER);
settingsButton.setImageResource(R.drawable.photo_paint_brush);
addView(settingsButton, LayoutHelper.createFrame(60, 52));
settingsButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (delegate != null) {
delegate.onSettingsPressed();
}
}
});
location = context.getSharedPreferences("paint", Activity.MODE_PRIVATE).getFloat("last_color_location", 1.0f);
setLocation(location);
}
示例2: onBindViewHolder
import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull VideoItem item) {
ImageView imageView = new ImageView(mActivity);
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
Glide.with(mActivity).load(item.data.cover.detailCover).into(imageView);
holder.videoView.setThumbImageView(imageView);
holder.videoView.setUp(item.data.playUrl, true, null);
holder.title.setText(item.data.title);
holder.title.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.DB1FontPath)));
holder.info.setText("#" + item.data.category + " / " + TranslateDuration.translateSeconds(item.data.duration));
holder.info.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.LFontPath)));
holder.description.setText(item.data.description);
holder.description.setTypeface(Typeface.createFromAsset(mActivity.getAssets(), mActivity.getString(R.string.LFontPath)));
}
示例3: initIconView
import android.widget.ImageView; //導入方法依賴的package包/類
private View initIconView() {
FrameLayout contentView = new FrameLayout(LiteIconActivity.this);
int gridW = (int) (displayMetrics.density * GRID_W_IN_DP);
int gridH = (int) (displayMetrics.density * GRID_H_IN_DP);
ViewGroup.LayoutParams lpCv = new ViewGroup.LayoutParams(gridW, gridH);
contentView.setLayoutParams(lpCv);
ImageView ivIcon = new ImageView(LiteIconActivity.this);
ivIcon.setTag("iv");
ivIcon.setScaleType(ImageView.ScaleType.FIT_CENTER);
ivIcon.setClickable(true);
ivIcon.setBackgroundResource(getClickBg());
int iconSize = (int) (displayMetrics.density * ICON_SIZE_IN_DP);
FrameLayout.LayoutParams lpIv = new FrameLayout.LayoutParams(iconSize, iconSize);
lpIv.gravity = Gravity.CENTER;
ivIcon.setLayoutParams(lpIv);
contentView.addView(ivIcon);
return contentView;
}
示例4: addIcon
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* 添加圖標
*/
private void addIcon(){
iconImageView = new ImageView(getContext());
iconImageView.setFocusable(false);
iconImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
iconImageView.setImageResource(iconResId);
int size = DimensUtils.dpToPx(getContext(),20);
LinearLayout.LayoutParams llp = new LayoutParams(size,size);
addView(iconImageView,llp);
}
示例5: setImageViewScaleTypeMatrix
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* Set's the ImageView's ScaleType to Matrix.
*/
private static void setImageViewScaleTypeMatrix(ImageView imageView) {
/**
* PhotoView sets it's own ScaleType to Matrix, then diverts all calls
* setScaleType to this.setScaleType automatically.
*/
if (null != imageView && !(imageView instanceof IPhotoView)) {
if (!ScaleType.MATRIX.equals(imageView.getScaleType())) {
imageView.setScaleType(ScaleType.MATRIX);
}
}
}
示例6: initThumbs
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* 初始化縮略圖
*/
private void initThumbs(){
final int frame = 15;
final int frameTime = videoDuration/frame*1000;
int thumbnailWidth = ll_thumbnail.getWidth()/frame;
for (int x=0; x<frame; x++){
ImageView imageView = new ImageView(this);
imageView.setLayoutParams(new ViewGroup.LayoutParams(thumbnailWidth, ViewGroup.LayoutParams.MATCH_PARENT));
imageView.setBackgroundColor(Color.parseColor("#666666"));
imageView.setScaleType(ImageView.ScaleType.CENTER);
ll_thumbnail.addView(imageView);
}
new AsyncTask<Void, Void, Boolean>() {
@Override
protected Boolean doInBackground(Void... params) {
MediaMetadataRetriever mediaMetadata= new MediaMetadataRetriever();
mediaMetadata.setDataSource(mContext, Uri.parse(path));
for (int x=0; x<frame; x++){
Bitmap bitmap = mediaMetadata.getFrameAtTime(frameTime*x, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
Message msg = myHandler.obtainMessage();
msg.obj = bitmap;
msg.arg1 = x;
myHandler.sendMessage(msg);
}
mediaMetadata.release();
return true;
}
@Override
protected void onPostExecute(Boolean result) {
}
}.execute();
}
示例7: SearchButton
import android.widget.ImageView; //導入方法依賴的package包/類
public SearchButton(Context context) {
super(context);
setBackgroundColor(0xff1a1a1a);
selector = new View(context);
selector.setBackgroundResource(R.drawable.list_selector);
addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.CENTER);
addView(imageView, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP));
textView1 = new TextView(context);
textView1.setTypeface(FontManager.instance().getTypeface());
textView1.setGravity(Gravity.CENTER_VERTICAL);
textView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView1.setTypeface(FontManager.instance().getTypeface());
textView1.setTextColor(0xffffffff);
textView1.setSingleLine(true);
textView1.setEllipsize(TextUtils.TruncateAt.END);
addView(textView1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 8, 4, 0));
textView2 = new TextView(context);
textView2.setTypeface(FontManager.instance().getTypeface());
textView2.setGravity(Gravity.CENTER_VERTICAL);
textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
textView2.setTypeface(FontManager.instance().getTypeface());
textView2.setTextColor(0xff666666);
textView2.setSingleLine(true);
textView2.setEllipsize(TextUtils.TruncateAt.END);
addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 26, 4, 0));
}
示例8: setImageViewScaleTypeMatrix
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* Set's the ImageView's ScaleType to Matrix.
*/
private static void setImageViewScaleTypeMatrix(ImageView imageView) {
if (null != imageView) {
if (imageView instanceof PhotoView) {
/**
* PhotoView sets it's own ScaleType to Matrix, then diverts all
* calls setScaleType to this.setScaleType. Basically we don't
* need to do anything here
*/
imageView.setScaleType(ScaleType.CENTER);
} else {
imageView.setScaleType(ScaleType.MATRIX);
}
}
}
示例9: initImages
import android.widget.ImageView; //導入方法依賴的package包/類
private void initImages() {
mImageViews = new ArrayList<>();
ViewPager.LayoutParams lp=new ViewPager.LayoutParams();
lp.gravity= Gravity.LEFT;
ImageView imageView1 = new ImageView(this);
imageView1.setImageResource(R.drawable.jay_fantexi);
imageView1.setScaleType(ImageView.ScaleType.CENTER_CROP);
ImageView imageView2 = new ImageView(this);
imageView2.setImageResource(R.drawable.jay_jay);
imageView2.setScaleType(ImageView.ScaleType.CENTER_CROP);
ImageView imageView3 = new ImageView(this);
imageView3.setImageResource(R.drawable.image2);
imageView3.setScaleType(ImageView.ScaleType.CENTER_CROP);
ImageView imageView4 = new ImageView(this);
imageView4.setImageResource(R.drawable.jay_jay);
imageView4.setScaleType(ImageView.ScaleType.CENTER_CROP);
ImageView imageView5 = new ImageView(this);
imageView5.setImageResource(R.drawable.logo);
imageView5.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView1.setLayoutParams(lp);
imageView2.setLayoutParams(lp);
imageView3.setLayoutParams(lp);
imageView4.setLayoutParams(lp);
imageView5.setLayoutParams(lp);
mImageViews.add(imageView1);
mImageViews.add(imageView2);
mImageViews.add(imageView3);
mImageViews.add(imageView4);
mImageViews.add(imageView5);
}
示例10: SearchButton
import android.widget.ImageView; //導入方法依賴的package包/類
public SearchButton(Context context) {
super(context);
setBackgroundColor(0xff1a1a1a);
selector = new View(context);
selector.setBackgroundResource(R.drawable.list_selector);
addView(selector, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
imageView = new ImageView(context);
imageView.setScaleType(ImageView.ScaleType.CENTER);
addView(imageView, LayoutHelper.createFrame(48, 48, Gravity.LEFT | Gravity.TOP));
textView1 = new TextView(context);
textView1.setGravity(Gravity.CENTER_VERTICAL);
textView1.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
textView1.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView1.setTextColor(0xffffffff);
textView1.setSingleLine(true);
textView1.setEllipsize(TextUtils.TruncateAt.END);
addView(textView1, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 8, 4, 0));
textView2 = new TextView(context);
textView2.setGravity(Gravity.CENTER_VERTICAL);
textView2.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 10);
textView2.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView2.setTextColor(0xff666666);
textView2.setSingleLine(true);
textView2.setEllipsize(TextUtils.TruncateAt.END);
addView(textView2, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.LEFT, 51, 26, 4, 0));
}
示例11: FrameLayout
import android.widget.ImageView; //導入方法依賴的package包/類
private void addIconTabBådeTekstOgBillede(final int position, int resId, String url, String title) {
FrameLayout tabfl = new FrameLayout(getContext());
ImageView tabi = new ImageView(getContext());
tabi.setContentDescription(title);
//Log.d(title+" "+resId + " Kanallogo URL="+url);
if (resId==0) {
Picasso.with(tabi.getContext())
.load(url).placeholder(null)
.into(tabi);
tabi.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
tabi.setAdjustViewBounds(true);
tabi.setVisibility(View.GONE);
} else {
tabi.setImageResource(resId);
tabi.setVisibility(View.INVISIBLE);
}
TextView tabt = new TextView(getContext());
tabt.setText(title);
tabt.setTypeface(App.skrift_gibson);
tabt.setGravity(Gravity.CENTER);
tabt.setSingleLine();
tabfl.addView(tabi);
tabfl.addView(tabt);
LayoutParams lp = (LayoutParams) tabi.getLayoutParams();
lp.gravity=Gravity.CENTER;
lp.width=lp.height=ViewGroup.LayoutParams.MATCH_PARENT;
lp = (LayoutParams) tabt.getLayoutParams();
lp.width=lp.height=ViewGroup.LayoutParams.MATCH_PARENT;
lp.gravity=Gravity.CENTER;
addTab(position, tabfl);
}
示例12: setImageViewScaleTypeMatrix
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* Sets the ImageView's ScaleType to Matrix.
*/
private static void setImageViewScaleTypeMatrix(ImageView imageView) {
/**
* PhotoView sets its own ScaleType to Matrix, then diverts all calls
* setScaleType to this.setScaleType automatically.
*/
if (null != imageView && !(imageView instanceof IPhotoView)) {
if (!ScaleType.MATRIX.equals(imageView.getScaleType())) {
imageView.setScaleType(ScaleType.MATRIX);
}
}
}
示例13: setBannerImageList
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* Sets the picture list
*
* @param imagesUrl picture list
*/
public void setBannerImageList(List<?> imagesUrl) {
if (imagesUrl == null || imagesUrl.size() <= 0) {
return;
}
count = imagesUrl.size();
initImages();
for (int i = 0; i <= count + 1; i++) {
ImageView iv = new ImageView(context);
iv.setScaleType(ImageView.ScaleType.FIT_XY);
Object url;
if (i == 0) {
url = imagesUrl.get(count - 1);
} else if (i == count + 1) {
url = imagesUrl.get(0);
} else {
url = imagesUrl.get(i - 1);
}
imageViews.add(iv);
if (defaultImage != -1)
Glide.with(context).load(url).centerCrop().crossFade().into(iv);
else
Glide.with(context).load(url).centerCrop().crossFade().placeholder(defaultImage).into(iv);
}
setData();
}
示例14: build
import android.widget.ImageView; //導入方法依賴的package包/類
/**
* Generate the view
* @param builder the configs
*/
public void build(EdSliderBuilder builder)
{
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
LinearLayout layout = new LinearLayout(getContext());
layout.setLayoutParams(params);
layout.setOrientation(LinearLayout.HORIZONTAL);
layout.setBackgroundResource(builder.backgroundResId);
layout.setClipChildren(false);
layout.setClipToPadding(false);
for (EdIcon edIcon : builder.list)
{
params = new LinearLayout.LayoutParams(builder.size, builder.size);
params.setMargins(builder.margin, builder.margin, builder.margin, builder.margin);
ImageView image = new ImageView(getContext());
image.setLayoutParams(params);
image.setImageResource(edIcon.drawableid);
image.setScaleType(ImageView.ScaleType.FIT_CENTER);
layout.addView(image);
}
this.addView(layout);
this.manager = builder.manager;
this.flags = new boolean[builder.list.size()];
this.boundary = builder.boundary;
this.isReversed = builder.isReversed;
}
示例15: IndicatorLayout
import android.widget.ImageView; //導入方法依賴的package包/類
public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
super(context);
mArrowImageView = new ImageView(context);
Drawable arrowD = getResources().getDrawable(R.drawable.indicator_arrow);
mArrowImageView.setImageDrawable(arrowD);
final int padding = getResources().getDimensionPixelSize(R.dimen.indicator_internal_padding);
mArrowImageView.setPadding(padding, padding, padding, padding);
addView(mArrowImageView);
int inAnimResId, outAnimResId;
switch (mode) {
case PULL_FROM_END:
inAnimResId = R.anim.slide_in_from_bottom;
outAnimResId = R.anim.slide_out_to_bottom;
setBackgroundResource(R.drawable.indicator_bg_bottom);
// Rotate Arrow so it's pointing the correct way
mArrowImageView.setScaleType(ScaleType.MATRIX);
Matrix matrix = new Matrix();
matrix.setRotate(180f, arrowD.getIntrinsicWidth() / 2f, arrowD.getIntrinsicHeight() / 2f);
mArrowImageView.setImageMatrix(matrix);
break;
default:
case PULL_FROM_START:
inAnimResId = R.anim.slide_in_from_top;
outAnimResId = R.anim.slide_out_to_top;
setBackgroundResource(R.drawable.indicator_bg_top);
break;
}
mInAnim = AnimationUtils.loadAnimation(context, inAnimResId);
mInAnim.setAnimationListener(this);
mOutAnim = AnimationUtils.loadAnimation(context, outAnimResId);
mOutAnim.setAnimationListener(this);
final Interpolator interpolator = new LinearInterpolator();
mRotateAnimation = new RotateAnimation(0, -180, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
0.5f);
mRotateAnimation.setInterpolator(interpolator);
mRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
mRotateAnimation.setFillAfter(true);
mResetRotateAnimation = new RotateAnimation(-180, 0, Animation.RELATIVE_TO_SELF, 0.5f,
Animation.RELATIVE_TO_SELF, 0.5f);
mResetRotateAnimation.setInterpolator(interpolator);
mResetRotateAnimation.setDuration(DEFAULT_ROTATION_ANIMATION_DURATION);
mResetRotateAnimation.setFillAfter(true);
}