當前位置: 首頁>>代碼示例>>Java>>正文


Java ImageView.getDrawable方法代碼示例

本文整理匯總了Java中android.widget.ImageView.getDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java ImageView.getDrawable方法的具體用法?Java ImageView.getDrawable怎麽用?Java ImageView.getDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.ImageView的用法示例。


在下文中一共展示了ImageView.getDrawable方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setDisplayMatrix

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public boolean setDisplayMatrix(Matrix finalMatrix) {
    if (finalMatrix == null)
        throw new IllegalArgumentException("Matrix cannot be null");

    ImageView imageView = getImageView();
    if (null == imageView)
        return false;

    if (null == imageView.getDrawable())
        return false;

    mSuppMatrix.set(finalMatrix);
    setImageViewMatrix(getDrawMatrix());
    checkMatrixBounds();

    return true;
}
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:19,代碼來源:PhotoViewAttacher.java

示例2: getFitCenterScaleFactor

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * Calculates the scale factor needed to scale a drawable to fill one view dimension while
 * the other drawable dimension maintains the  correct aspect ratio while remaining inside the
 * view.
 *
 * @param imageView the view with a drawable to be centered
 * @return the scale factor
 */
private static float getFitCenterScaleFactor(@Nullable ImageView imageView) {
    if (imageView == null || imageView.getDrawable() == null) {
        return NO_SCALE;
    }

    Drawable drawable = imageView.getDrawable();
    int drawableWidth = drawable.getIntrinsicWidth();
    int drawableHeight = drawable.getIntrinsicHeight();
    int viewWidth = getViewWidthMinusPadding(imageView);
    int viewHeight = getViewHeightMinusPadding(imageView);
    if (drawableWidth <= 0 || drawableHeight <= 0 || viewWidth <= 0 || viewHeight <= 0) {
        return NO_SCALE;
    }

    float xScaling = ((float) viewWidth) / drawableWidth;
    float yScaling = ((float) viewHeight) / drawableHeight;

    // Always just pick the smallest dimension
    return Math.min(xScaling, yScaling);
}
 
開發者ID:metagalactic,項目名稱:ScalableImageView,代碼行數:29,代碼來源:ScalableImageView.java

示例3: computeImageWidthAndHeight

import android.widget.ImageView; //導入方法依賴的package包/類
/** 計算圖片的寬高 */
private void computeImageWidthAndHeight(ImageView imageView) {

    // 獲取真實大小
    Drawable drawable = imageView.getDrawable();
    int intrinsicHeight = drawable.getIntrinsicHeight();
    int intrinsicWidth = drawable.getIntrinsicWidth();
    // 計算出與屏幕的比例,用於比較以寬的比例為準還是高的比例為準,因為很多時候不是高度沒充滿,就是寬度沒充滿
    float h = screenHeight * 1.0f / intrinsicHeight;
    float w = screenWidth * 1.0f / intrinsicWidth;
    if (h > w) h = w;
    else w = h;

    // 得出當寬高至少有一個充滿的時候圖片對應的寬高
    imageHeight = (int) (intrinsicHeight * h);
    imageWidth = (int) (intrinsicWidth * w);
}
 
開發者ID:zuoweitan,項目名稱:Hitalk,代碼行數:18,代碼來源:ImagePreviewActivity.java

示例4: Builder

import android.widget.ImageView; //導入方法依賴的package包/類
public Builder(ImageView imageView) {
    viewRef = new WeakReference<>(imageView);
    if (imageView.getScaleType() != ImageView.ScaleType.MATRIX) {
        throw new IllegalStateException("the image scaleType must be ScaleType.MATRIX");
    }

    Drawable d = imageView.getDrawable();
    if (d != null) {
        animCenterX = d.getIntrinsicWidth() / 2;
        animCenterY = d.getIntrinsicHeight() / 2;
    }

    Matrix matrix = new Matrix(imageView.getImageMatrix());
    fromDegrees = toDegrees = MatrixUtils.getMatrixAngle(matrix);
    fromScaleX = toScaleX = getMatrixScaleX(matrix);
    fromScaleY = toScaleY = getMatrixScaleY(matrix);

    float[] txty = calculateTxTy();
    fromTranslateX = toTranslateX = txty[0];
    fromTranslateY = toTranslateY = txty[1];

}
 
開發者ID:xyzxqs,項目名稱:XphotoView,代碼行數:23,代碼來源:ImageMatrixAnimator.java

示例5: onCreate

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search_result);

        final TextView search_result_back = (TextView) findViewById(R.id.search_result_back);
        final ListView search_result_list = (ListView) findViewById(R.id.search_result_list);
        img = (ImageView) findViewById(R.id.imageView3);
        ArrayAdapter<String> adapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, Item.searchList);
        search_result_list.setAdapter(adapter);
        TransitionDrawable animation = (TransitionDrawable)img.getDrawable();
        animation.startTransition(3000);
        animation.reverseTransition(3000);
//        img.setBackgroundResource(R.drawable.trans);
//        AnimationDrawable frameAnimation = (AnimationDrawable) img.getBackground();
//        frameAnimation.start();
        search_result_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Item.searchList.clear();
                goToSearch();
            }
        });
    }
 
開發者ID:IvoryCandy,項目名稱:Plus1s,代碼行數:26,代碼來源:SearchResultActivity.java

示例6: getRefreshHeaderView

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
public View getRefreshHeaderView() {
    if (mRefreshHeaderView == null) {
        mRefreshHeaderView = View.inflate(mContext, R.layout.view_refresh_header_normal, null);
        mRefreshHeaderView.setBackgroundColor(Color.TRANSPARENT);
        if (mRefreshViewBackgroundColorRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundColorRes);
        }
        if (mRefreshViewBackgroundDrawableRes != -1) {
            mRefreshHeaderView.setBackgroundResource(mRefreshViewBackgroundDrawableRes);
        }
        mHeaderStatusTv = (TextView) mRefreshHeaderView.findViewById(R.id.tv_normal_refresh_header_status);
        mHeaderArrowIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_arrow);
        mHeaderChrysanthemumIv = (ImageView) mRefreshHeaderView.findViewById(R.id.iv_normal_refresh_header_chrysanthemum);
        mHeaderChrysanthemumAd = (AnimationDrawable) mHeaderChrysanthemumIv.getDrawable();
        mHeaderStatusTv.setText(mPullDownRefreshText);
    }
    return mRefreshHeaderView;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:BGANormalRefreshViewHolder.java

示例7: convertTargetInfo

import android.widget.ImageView; //導入方法依賴的package包/類
void convertTargetInfo(ImageView tarView, Context context) {
    if (tarView == null || tarView.getDrawable() == null) {
        throw new NullPointerException("target ImageView or ImageView drawable must not null");
    }

    //get target ImageView info
    tarView.getImageMatrix().getValues(mTargetValues);
    Rect tarRect = tarView.getDrawable().getBounds();
    mTargetWidth = (int) (tarRect.width() * mTargetValues[Matrix.MSCALE_X]);
    mTargetHeight = (int) (tarRect.height() * mTargetValues[Matrix.MSCALE_Y]);

    mTargetViewWidth = tarView.getWidth();
    mTargetViewHeight = tarView.getHeight();
    tarView.getLocationOnScreen(mTargetLocation);

    init(context);
}
 
開發者ID:idisfkj,項目名稱:AndroidShareElement,代碼行數:18,代碼來源:ShareElementInfo.java

示例8: onCreate

import android.widget.ImageView; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_open_on_phone_animation);

    AmbientMode.attachAmbientSupport(this);

    mAnimationCallback =
            new AnimationCallback() {
                @Override
                public void onAnimationEnd(Drawable drawable) {
                    super.onAnimationEnd(drawable);
                    // Go back to main Dialogs screen after animation.
                    finish();
                }
            };

    // Play 'swipe left' animation only once.
    ImageView phoneImage = findViewById(R.id.open_on_phone_animation_image);
    mAnimatedVectorDrawablePhone = (AnimatedVectorDrawable) phoneImage.getDrawable();
    mAnimatedVectorDrawablePhone.registerAnimationCallback(mAnimationCallback);
    mAnimatedVectorDrawablePhone.start();
}
 
開發者ID:googlesamples,項目名稱:android-WearAccessibilityApp,代碼行數:24,代碼來源:OpenOnPhoneAnimationActivity.java

示例9: getDisplayRect

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * Helper method that maps the supplied Matrix to the current Drawable
 * 
 * @param matrix
 *            - Matrix to map Drawable against
 * @return RectF - Displayed Rectangle
 */
private RectF getDisplayRect(Matrix matrix) {
	ImageView imageView = getImageView();

	if (null != imageView) {
		Drawable d = imageView.getDrawable();
		if (null != d) {
			mDisplayRect.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
			matrix.mapRect(mDisplayRect);
			return mDisplayRect;
		}
	}
	return null;
}
 
開發者ID:turoDog,項目名稱:KTalk,代碼行數:21,代碼來源:PhotoViewAttacher.java

示例10: getDisplayRect

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * Helper method that maps the supplied Matrix to the current Drawable
 *
 * @param matrix - Matrix to map Drawable against
 * @return RectF - Displayed Rectangle
 */
private RectF getDisplayRect(Matrix matrix) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        Drawable d = imageView.getDrawable();
        if (null != d) {
            mDisplayRect.set(0, 0, d.getIntrinsicWidth(),
                    d.getIntrinsicHeight());
            matrix.mapRect(mDisplayRect);
            return mDisplayRect;
        }
    }
    return null;
}
 
開發者ID:snowwolf10285,項目名稱:PicShow-zhaipin,代碼行數:21,代碼來源:PhotoViewAttacher.java

示例11: convertOriginalInfo

import android.widget.ImageView; //導入方法依賴的package包/類
public void convertOriginalInfo(ImageView oriView) {
    if (oriView == null || oriView.getDrawable() == null) {
        throw new NullPointerException("original ImageView or ImageView drawable must not null");
    }

    //get original ImageView info
    oriView.getImageMatrix().getValues(mOriginalValues);
    Rect oriRect = oriView.getDrawable().getBounds();
    mOriginalWidth = (int) (oriRect.width() * mOriginalValues[Matrix.MSCALE_X]);
    mOriginalHeight = (int) (oriRect.height() * mOriginalValues[Matrix.MSCALE_Y]);

    mOriginalViewWidth = oriView.getWidth();
    mOriginalViewHeight = oriView.getHeight();
    oriView.getLocationOnScreen(mOriginalLocation);
}
 
開發者ID:idisfkj,項目名稱:AndroidShareElement,代碼行數:16,代碼來源:ShareElementInfo.java

示例12: startAnimationDrawable

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * 播放幀動畫
 *
 * @param target target
 * @return
 */
public static AnimationDrawable startAnimationDrawable(ImageView target) {
    AnimationDrawable animationDrawable = (AnimationDrawable) target.getDrawable();
    if (animationDrawable != null) {
        target.setVisibility(View.VISIBLE);
        animationDrawable.start();
    }
    return animationDrawable;
}
 
開發者ID:wilsonchouu,項目名稱:LiveGiftView,代碼行數:15,代碼來源:GiftAnimationUtils.java

示例13: getBase64

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * Se transforma el contenido de un ImageView en un String base64 para enviar al servidor.
 *
 * @param imageView
 * @return
 */
public String getBase64(ImageView imageView) {
    BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
    Bitmap bitmap = drawable.getBitmap();
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    bitmap.compress(Bitmap.CompressFormat.PNG, 100, bos);
    byte[] bb = bos.toByteArray();
    String image = Base64.encodeToString(bb, 0);

    return image;
}
 
開發者ID:ur13l,項目名稱:Guanajoven,代碼行數:17,代碼來源:EditarDatosFragment.java

示例14: initView

import android.widget.ImageView; //導入方法依賴的package包/類
public void initView(Context context) {
    LayoutInflater.from(context).inflate(R.layout.yun_refresh_footer, this);
    mText = (TextView) findViewById(R.id.msg);
    mIvProgress = (ImageView) findViewById(R.id.iv_progress);
    mAnimationDrawable = (AnimationDrawable) mIvProgress.getDrawable();
    if (!mAnimationDrawable.isRunning()) {
        mAnimationDrawable.start();
    }
    setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:LoadingMoreFooter.java

示例15: hasDrawable

import android.widget.ImageView; //導入方法依賴的package包/類
/**
 * @return true if the ImageView exists, and it's Drawable existss
 */
private static boolean hasDrawable(ImageView imageView) {
    return null != imageView && null != imageView.getDrawable();
}
 
開發者ID:yun2win,項目名稱:tvConnect_android,代碼行數:7,代碼來源:PhotoViewAttacher.java


注:本文中的android.widget.ImageView.getDrawable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。