当前位置: 首页>>代码示例>>Java>>正文


Java ImageView.setScaleType方法代码示例

本文整理汇总了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);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:25,代码来源:ColorPicker.java

示例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)));
}
 
开发者ID:KnowledgeBegger,项目名称:MyEyepetizer,代码行数:18,代码来源:SubjectItemBinder.java

示例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;
}
 
开发者ID:by-syk,项目名称:NanoIconPackLite,代码行数:21,代码来源:LiteIconActivity.java

示例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);

}
 
开发者ID:VK2012,项目名称:AppCommonFrame,代码行数:15,代码来源:BottomNavButton.java

示例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);
        }
    }
}
 
开发者ID:Loofer,项目名称:Watermark,代码行数:15,代码来源:PhotoViewAttacher.java

示例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();
}
 
开发者ID:Zhaoss,项目名称:WeiXinRecordedDemo,代码行数:38,代码来源:CutTimeActivity.java

示例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));
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:34,代码来源:PhotoPickerSearchCell.java

示例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);
		}
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:18,代码来源:PhotoViewAttacher.java

示例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);
}
 
开发者ID:youngkaaa,项目名称:YViewPagerDemo,代码行数:39,代码来源:MainActivity.java

示例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));
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:32,代码来源:PhotoPickerSearchCell.java

示例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);
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:36,代码来源:PagerSlidingTabStrip.java

示例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);
        }
    }
}
 
开发者ID:WeiXinqiao,项目名称:Recognize-it,代码行数:15,代码来源:PhotoViewAttacher.java

示例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();
}
 
开发者ID:shenhuanet,项目名称:AndroidOpen,代码行数:32,代码来源:BannerView.java

示例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;
}
 
开发者ID:Emadoki,项目名称:edslider,代码行数:35,代码来源:EdSliderView.java

示例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);

}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:53,代码来源:IndicatorLayout.java


注:本文中的android.widget.ImageView.setScaleType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。