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


Java ScaleType类代码示例

本文整理汇总了Java中android.widget.ImageView.ScaleType的典型用法代码示例。如果您正苦于以下问题:Java ScaleType类的具体用法?Java ScaleType怎么用?Java ScaleType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


ScaleType类属于android.widget.ImageView包,在下文中一共展示了ScaleType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkImageViewScaleType

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
private void checkImageViewScaleType() {
	ImageView imageView = getImageView();

	/**
	 * PhotoView's getScaleType() will just divert to this.getScaleType() so
	 * only call if we're not attached to a PhotoView.
	 */
	if (null != imageView && !(imageView instanceof PhotoView)) {
		if (imageView.getScaleType() != ScaleType.MATRIX) {
			throw new IllegalStateException(
					"The ImageView's ScaleType has been changed since attaching a PhotoViewAttacher");
		}
	}
}
 
开发者ID:mangestudio,项目名称:GCSApp,代码行数:15,代码来源:PhotoViewAttacher.java

示例2: getResizeMode

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
private ScaleType getResizeMode(String resizeMode) {
    ScaleType scaleType = ScaleType.FIT_XY;
    if (TextUtils.isEmpty(resizeMode)) {
        return scaleType;
    }

    if (resizeMode.equals("cover")) {
        scaleType = ScaleType.CENTER_CROP;
    } else if (resizeMode.equals("contain")) {
        scaleType = ScaleType.FIT_CENTER;
    } else if (resizeMode.equals("stretch")) {
        scaleType = ScaleType.FIT_XY;
    } else if (resizeMode.equals("center")) {
        scaleType = ScaleType.CENTER;
    } else if (resizeMode.equals("start")) {
        scaleType = ScaleType.MATRIX;
    } else if (resizeMode.equals("end")) {
        scaleType = ScaleType.FIT_END;
    }
    return scaleType;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:22,代码来源:WXImage.java

示例3: onCreate

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
public void onCreate() {
	startSensor();

	int resId = getBitmapRes(activity, "ssdk_oks_yaoyiyao");
	if (resId > 0) {
		ImageView iv = new ImageView(activity);
		iv.setScaleType(ScaleType.CENTER_INSIDE);
		iv.setImageResource(resId);
		activity.setContentView(iv);
	}

	resId = getStringRes(activity, "shake2share");
	if (resId > 0) {
		Toast.makeText(activity, resId, Toast.LENGTH_SHORT).show();
	}
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:17,代码来源:Shake2Share.java

示例4: RotateLoadingLayout

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
public RotateLoadingLayout(Context context, Mode mode, Orientation scrollDirection, TypedArray attrs) {
	super(context, mode, scrollDirection, attrs);

	mRotateDrawableWhilePulling = attrs.getBoolean(R.styleable.PullToRefresh_ptrRotateDrawableWhilePulling, true);

	mHeaderImage.setScaleType(ScaleType.MATRIX);
	mHeaderImageMatrix = new Matrix();
	mHeaderImage.setImageMatrix(mHeaderImageMatrix);

	mRotateAnimation = new RotateAnimation(0, 720, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
			0.5f);
	mRotateAnimation.setInterpolator(ANIMATION_INTERPOLATOR);
	mRotateAnimation.setDuration(ROTATION_ANIMATION_DURATION);
	mRotateAnimation.setRepeatCount(Animation.INFINITE);
	mRotateAnimation.setRepeatMode(Animation.RESTART);
}
 
开发者ID:ccfish86,项目名称:sctalk,代码行数:17,代码来源:RotateLoadingLayout.java

示例5: setImageViewScaleTypeMatrix

import android.widget.ImageView.ScaleType; //导入依赖的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

示例6: addListener

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
protected void addListener() {
    this.mHeaderView = new ImageView(getActivity());
    this.mHeaderView.setScaleType(ScaleType.CENTER_CROP);
    this.mHeaderView.setLayoutParams(new LayoutParams(-1, -2));
    ((ListView) this.mPullRefreshListView.getRefreshableView()).addHeaderView(this.mHeaderView);
    this.mAdapter = new HomeTimelineAdapter(getActivity(), this.mPosts);
    this.mPullRefreshListView.setAdapter(this.mAdapter);
    this.mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
            GoodsPostsFragment.this.getCurrentTopic();
        }
    });
    this.mPullRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() {
        public void onLastItemVisible() {
            if (!GoodsPostsFragment.this.isLastVisible) {
                GoodsPostsFragment.this.getNextTopic();
            }
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:21,代码来源:GoodsPostsFragment.java

示例7: onCreate

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
protected final void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    Context context = getContext();
    View linearLayout = new LinearLayout(context);
    LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, a(context, (float) IntFloatWheelView.DEFAULT_VALUE));
    layoutParams.gravity = 17;
    linearLayout.setOrientation(0);
    linearLayout.setLayoutParams(layoutParams);
    Drawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(-450944201);
    gradientDrawable.setCornerRadius((float) a(context, 5.0f));
    linearLayout.setBackgroundDrawable(gradientDrawable);
    View imageView = new ImageView(context);
    layoutParams = new LinearLayout.LayoutParams(a(context, 20.0f), a(context, 20.0f));
    layoutParams.gravity = 16;
    layoutParams.setMargins(a(this.a.f, 17.0f), a(this.a.f, 10.0f), a(this.a.f, 8.0f), a(this.a.f, 10.0f));
    imageView.setLayoutParams(layoutParams);
    imageView.setScaleType(ScaleType.FIT_CENTER);
    imageView.setImageDrawable(a(context, a.d));
    Animation rotateAnimation = new RotateAnimation(0.0f, 359.0f, 1, 0.5f, 1, 0.5f);
    rotateAnimation.setRepeatCount(-1);
    rotateAnimation.setDuration(900);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    imageView.startAnimation(rotateAnimation);
    View textView = new TextView(context);
    textView.setText(TextUtils.isEmpty(this.a.g) ? a.a : this.a.g);
    textView.setTextSize(16.0f);
    textView.setTextColor(-1);
    layoutParams = new LinearLayout.LayoutParams(-2, -2);
    layoutParams.gravity = 16;
    layoutParams.setMargins(0, 0, a(context, 17.0f), 0);
    textView.setLayoutParams(layoutParams);
    linearLayout.addView(imageView);
    linearLayout.addView(textView);
    setContentView(linearLayout);
    setCancelable(false);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:38,代码来源:a.java

示例8: get

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
public ImageContainer get(String requestUrl, ImageListener imageListener, int maxWidth, int maxHeight, ScaleType scaleType) {
    throwIfNotOnMainThread();
    String cacheKey = getCacheKey(requestUrl, maxWidth, maxHeight, scaleType);
    Bitmap cachedBitmap = this.mCache.getBitmap(cacheKey);
    if (cachedBitmap != null) {
        ImageContainer container = new ImageContainer(cachedBitmap, requestUrl, null, null);
        imageListener.onResponse(container, true);
        return container;
    }
    ImageContainer imageContainer = new ImageContainer(null, requestUrl, cacheKey, imageListener);
    imageListener.onResponse(imageContainer, true);
    BatchedImageRequest request = (BatchedImageRequest) this.mInFlightRequests.get(cacheKey);
    if (request != null) {
        request.addContainer(imageContainer);
        return imageContainer;
    }
    Request<Bitmap> newRequest = makeImageRequest(requestUrl, maxWidth, maxHeight, scaleType, cacheKey);
    this.mRequestQueue.add(newRequest);
    this.mInFlightRequests.put(cacheKey, new BatchedImageRequest(newRequest, imageContainer));
    return imageContainer;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:22,代码来源:ImageLoader.java

示例9: a

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
private View a(Context context) {
    View linearLayout = new LinearLayout(context);
    LayoutParams layoutParams = new FrameLayout.LayoutParams(-2, a(context, (float) IntFloatWheelView.DEFAULT_VALUE));
    layoutParams.gravity = 17;
    linearLayout.setOrientation(0);
    linearLayout.setLayoutParams(layoutParams);
    Drawable gradientDrawable = new GradientDrawable();
    gradientDrawable.setColor(-450944201);
    gradientDrawable.setCornerRadius((float) a(context, 5.0f));
    linearLayout.setBackgroundDrawable(gradientDrawable);
    View imageView = new ImageView(context);
    layoutParams = new LinearLayout.LayoutParams(a(context, 20.0f), a(context, 20.0f));
    layoutParams.gravity = 16;
    layoutParams.setMargins(a(this.a.f, 17.0f), a(this.a.f, 10.0f), a(this.a.f, 8.0f), a(this.a.f, 10.0f));
    imageView.setLayoutParams(layoutParams);
    imageView.setScaleType(ScaleType.FIT_CENTER);
    imageView.setImageDrawable(a(context, a.d));
    Animation rotateAnimation = new RotateAnimation(0.0f, 359.0f, 1, 0.5f, 1, 0.5f);
    rotateAnimation.setRepeatCount(-1);
    rotateAnimation.setDuration(900);
    rotateAnimation.setInterpolator(new LinearInterpolator());
    imageView.startAnimation(rotateAnimation);
    View textView = new TextView(context);
    textView.setText(TextUtils.isEmpty(this.a.g) ? a.a : this.a.g);
    textView.setTextSize(16.0f);
    textView.setTextColor(-1);
    layoutParams = new LinearLayout.LayoutParams(-2, -2);
    layoutParams.gravity = 16;
    layoutParams.setMargins(0, 0, a(context, 17.0f), 0);
    textView.setLayoutParams(layoutParams);
    linearLayout.addView(imageView);
    linearLayout.addView(textView);
    return linearLayout;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:35,代码来源:a.java

示例10: adjustCanvasForBorder

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
private void adjustCanvasForBorder(Canvas canvas) {
    float[] values = new float[9];
    canvas.getMatrix().getValues(values);
    float scaleFactorX = values[0];
    float scaleFactorY = values[4];
    float translateX = values[2];
    float translateY = values[5];
    float newScaleX = this.mBounds.width() / ((this.mBounds.width() + this.mBorderWidth)
            + this.mBorderWidth);
    float newScaleY = this.mBounds.height() / ((this.mBounds.height() + this
            .mBorderWidth) + this.mBorderWidth);
    canvas.scale(newScaleX, newScaleY);
    if (ScaleType.FIT_START == this.mScaleType || ScaleType.FIT_END == this.mScaleType ||
            ScaleType.FIT_XY == this.mScaleType || ScaleType.FIT_CENTER == this
            .mScaleType || ScaleType.CENTER_INSIDE == this.mScaleType || ScaleType.MATRIX
            == this.mScaleType) {
        canvas.translate(this.mBorderWidth, this.mBorderWidth);
    } else if (ScaleType.CENTER == this.mScaleType || ScaleType.CENTER_CROP == this
            .mScaleType) {
        canvas.translate((-translateX) / (newScaleX * scaleFactorX), (-translateY) /
                (newScaleY * scaleFactorY));
        canvas.translate(-(this.mBounds.left - this.mBorderWidth), -(this.mBounds.top -
                this.mBorderWidth));
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:26,代码来源:SelectableRoundedImageView.java

示例11: onCreate

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
public void onCreate() {
	ivViewer = new ImageView(activity);
	ivViewer.setScaleType(ScaleType.CENTER_INSIDE);
	ivViewer.setBackgroundColor(0xc0000000);
	ivViewer.setOnClickListener(this);
	activity.setContentView(ivViewer);
	if (pic != null && !pic.isRecycled()) {
		ivViewer.setImageBitmap(pic);
	}
}
 
开发者ID:SShineTeam,项目名称:Huochexing12306,代码行数:11,代码来源:PicViewer.java

示例12: setScaleType

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
public void setScaleType(ScaleType scaleType) {
    if (!$assertionsDisabled && scaleType == null) {
        throw new AssertionError();
    } else if (this.mScaleType != scaleType) {
        this.mScaleType = scaleType;
        switch (1.$SwitchMap$android$widget$ImageView$ScaleType[scaleType.ordinal()]) {
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
                super.setScaleType(ScaleType.FIT_XY);
                break;
            default:
                super.setScaleType(scaleType);
                break;
        }
        updateDrawableAttrs();
        updateBackgroundDrawableAttrs(false);
        invalidate();
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:25,代码来源:RoundedImageView.java

示例13: findViews

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
private void findViews() {
    this.fab_button = (FloatingActionButton) findViewById(R.id.fab_button);
    this.fab_button.setVisibility(8);
    this.mHeaderView = new ImageView(this);
    this.mHeaderView.setScaleType(ScaleType.CENTER_CROP);
    this.mHeaderView.setLayoutParams(new LayoutParams(-1, -2));
    this.mPullRefreshListView = (PullToRefreshListView) findViewById(R.id.listview);
    this.mListView = (ListView) this.mPullRefreshListView.getRefreshableView();
    this.mListView.addHeaderView(this.mHeaderView);
    this.mPullRefreshListView.setOnRefreshListener(new OnRefreshListener<ListView>() {
        public void onRefresh(PullToRefreshBase<ListView> pullToRefreshBase) {
            ChannelPostsActivity.this.getCurrentTopic();
        }
    });
    this.mPullRefreshListView.setOnLastItemVisibleListener(new OnLastItemVisibleListener() {
        public void onLastItemVisible() {
            if (!ChannelPostsActivity.this.isLastVisible) {
                ChannelPostsActivity.this.getNextTopic();
            }
        }
    });
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:23,代码来源:ChannelPostsActivity.java

示例14: addImage

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
/**
 * Adds new image to container view
 *
 * @param logImage LogImage object, if null, adds new image indicator instead
 * @param index    Image index
 */
private void addImage(LogImage logImage, int index) {
    WebImageView imageView = new WebImageView(mWorkContext.getContext());
    DiaryImage diaryImage = new DiaryImage(imageView);
    diaryImage.index = index;
    if (logImage != null) {
        changeImage(diaryImage, logImage);
    } else {
        mAddButton = imageView;
        imageView.setImageDrawable(mWorkContext.getContext().getResources().getDrawable(R.drawable.ic_camera));
        imageView.setBackgroundResource(R.drawable.bg_image_button);
    }
    LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams((int) mWorkContext.getContext().getResources().getDimension(R.dimen.logimage_size),
            (int) mWorkContext.getContext().getResources().getDimension(R.dimen.logimage_size));
    imageView.setLayoutParams(layoutParams);
    imageView.setScaleType(ScaleType.CENTER_CROP);
    mContainerView.addView(imageView);
    mDiaryImages.add(diaryImage);
    setupImageEdit(diaryImage, imageView, index);
}
 
开发者ID:suomenriistakeskus,项目名称:oma-riista-android,代码行数:26,代码来源:DiaryImageManager.java

示例15: onLoadingDrawableSet

import android.widget.ImageView.ScaleType; //导入依赖的package包/类
@Override
protected void onLoadingDrawableSet(Drawable imageDrawable) {
	if (null != imageDrawable) {
		final int dHeight = imageDrawable.getIntrinsicHeight();
		final int dWidth = imageDrawable.getIntrinsicWidth();

		/**
		 * We need to set the width/height of the ImageView so that it is
		 * square with each side the size of the largest drawable dimension.
		 * This is so that it doesn't clip when rotated.
		 */
		ViewGroup.LayoutParams lp = mHeaderImage.getLayoutParams();
		lp.width = lp.height = Math.max(dHeight, dWidth);
		mHeaderImage.requestLayout();

		/**
		 * We now rotate the Drawable so that is at the correct rotation,
		 * and is centered.
		 */
		mHeaderImage.setScaleType(ScaleType.MATRIX);
		Matrix matrix = new Matrix();
		matrix.postTranslate((lp.width - dWidth) / 2f, (lp.height - dHeight) / 2f);
		matrix.postRotate(getDrawableRotationAngle(), lp.width / 2f, lp.height / 2f);
		mHeaderImage.setImageMatrix(matrix);
	}
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:27,代码来源:FlipLoadingLayout.java


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