Example usage for android.graphics.drawable Drawable getIntrinsicHeight

List of usage examples for android.graphics.drawable Drawable getIntrinsicHeight

Introduction

In this page you can find the example usage for android.graphics.drawable Drawable getIntrinsicHeight.

Prototype

public int getIntrinsicHeight() 

Source Link

Document

Returns the drawable's intrinsic height.

Usage

From source file:com.shizhefei.view.largeimage.LargeImageView.java

@Override
public void setImageDrawable(Drawable drawable) {
    mFactory = null;//  ww  w.j av  a 2  s .  com
    mScale = 1.0f;
    scrollTo(0, 0);
    if (mDrawable != drawable) {
        final int oldWidth = mDrawableWidth;
        final int oldHeight = mDrawableHeight;
        updateDrawable(drawable);
        onLoadImageSize(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
        if (oldWidth != mDrawableWidth || oldHeight != mDrawableHeight) {
            requestLayout();
        }
        notifyInvalidate();
    }
}

From source file:it.ndorigatti.android.view.MulticolorProgressBar.java

@Override
protected synchronized void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    Drawable d = mCurrentDrawable;

    int dw = 0;/*from  ww w  .j  a v a  2  s. c  o m*/
    int dh = 0;
    if (d != null) {
        dw = Math.max(mMinWidth, Math.min(mMaxWidth, d.getIntrinsicWidth()));
        dh = Math.max(mMinHeight, Math.min(mMaxHeight, d.getIntrinsicHeight()));
    }
    updateDrawableState();
    dw += getPaddingLeft() + getPaddingRight();
    dh += getPaddingTop() + getPaddingBottom();

    setMeasuredDimension(resolveSizeAndState(dw, widthMeasureSpec, 0),
            resolveSizeAndState(dh, heightMeasureSpec, 0));
}

From source file:cn.djangoogle.pull2load.internal.IndicatorLayout.java

public IndicatorLayout(Context context, Pull2LoadBase.Mode mode) {
    super(context);
    mArrowImageView = new ImageView(context);

    Drawable arrowD = ContextCompat.getDrawable(context, 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);//  w w w .  j  av a  2 s.  com

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

}

From source file:library.internal.IndicatorLayout.java

public IndicatorLayout(Context context, PullToRefreshBase.Mode mode) {
    super(context);
    mArrowImageView = new ImageView(context);

    Drawable arrowD = ContextCompat.getDrawable(context, 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);//from w  ww.  j  ava  2 s  .  c o  m

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

}

From source file:com.guodong.sun.guodong.widget.ZoomImageView.java

/**
 * ???l,r,t,b//from  w  w w . j  av a  2 s .co  m
 *
 * @return
 */
private RectF getMatrixRectF() {

    Matrix matrix = mScaleMatrix;
    RectF rectF = new RectF();
    Drawable d = getDrawable();

    if (d != null) {

        rectF.set(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight());
        matrix.mapRect(rectF);
    }
    return rectF;
}

From source file:com.goka.flickableview.ImageViewTouchBase.java

protected void updateDrawable(Drawable newDrawable) {
    if (null != newDrawable) {
        mBitmapRect.set(0, 0, newDrawable.getIntrinsicWidth(), newDrawable.getIntrinsicHeight());
    } else {//  www  .java 2s .c  om
        mBitmapRect.setEmpty();
    }
}

From source file:com.tpos.widget.pagertab.PagerSlidingTabStrip.java

private void addIconTextTab(final int position, int resId, String title) {

    TextView tab = (TextView) LayoutInflater.from(getContext()).inflate(R.layout.item_tabstrip_view, null);
    // new TextView(getContext());
    tab.setText(title);//from w ww.  ja va  2  s. c  o m
    tab.setGravity(Gravity.CENTER);
    tab.setSingleLine();

    Drawable tDrawable = null;
    try {
        tDrawable = getResources().getDrawable(resId);
    } catch (NotFoundException e) {
        e.printStackTrace();
        tDrawable = null;
    }
    if (tDrawable != null) {
        tDrawable.setBounds(0, 0, (int) (tDrawable.getIntrinsicWidth() * 0.5),
                (int) (tDrawable.getIntrinsicHeight() * 0.5));
        tab.setCompoundDrawables(null, tDrawable, null, null);
    }

    addTab(position, tab);

}

From source file:de.grobox.liberario.activities.MapActivity.java

private Bitmap getBitmap(Drawable drawable) {
    Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight(),
            Bitmap.Config.ARGB_8888);/*from  w w w .j a  v a2s  . c  o m*/
    Canvas canvas = new Canvas(bitmap);
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
    drawable.draw(canvas);
    return bitmap;
}

From source file:lewa.support.v7.internal.view.menu.ActionMenuItemView.java

/** @hide */
//@LewaHook(LewaHook.LewaHookType.NEW_METHOD)
public void setIcon(Drawable icon, int color) {
    if (mIcon == icon) {
        return;//  w  w  w .j  a v  a 2  s  .  c o m
    }

    mIcon = null;
    mIcon = icon;
    if (icon != null) {
        // LEWA ADD BEGIN
        mColorfulIcon = null;
        mColorfulIcon = Injector.resetActionModeDrawableColor(this, icon, color);
        // LEWA ADD END

        int width = icon.getIntrinsicWidth();
        int height = icon.getIntrinsicHeight();
        if (width > mMaxIconSize) {
            final float scale = (float) mMaxIconSize / width;
            width = mMaxIconSize;
            height *= scale;
        }
        if (height > mMaxIconSize) {
            final float scale = (float) mMaxIconSize / height;
            height = mMaxIconSize;
            width *= scale;
        }
        // LEWA MODIFY BEGIN
        if (true) {
            mColorfulIcon.setBounds(0, 0, width, height);
        } else {
            icon.setBounds(0, 0, width, height);
        }
        // LEWA MODIFY END
    }
    // LEWA MODIFY BEGIN
    if (true) {
        // Set icon at top in Lewa OS
        setCompoundDrawables(null, mColorfulIcon, null, null);
    } else {
        setCompoundDrawables(icon, null, null, null);
    }
    // LEWA MODIFY END

    updateTextButtonVisibility();
}

From source file:com.tpos.widget.pagertab.PagerSlidingTabStrip.java

/**
 * Tab/*from   w  ww.j a va2  s  .co  m*/
 */
private void setSelectedTabIcon(int position, int resId) {
    // update steven
    updateTabStyles();
    View v = tabsContainer.getChildAt(position);
    if (v instanceof TextView) {
        Drawable tDrawable = null;
        try {
            tDrawable = getResources().getDrawable(resId);
        } catch (NotFoundException e) {
            e.printStackTrace();
            tDrawable = null;
        }
        if (tDrawable != null) {
            tDrawable.setBounds(0, 0, (int) (tDrawable.getIntrinsicWidth() * 0.5),
                    (int) (tDrawable.getIntrinsicHeight() * 0.5));
            ((TextView) v).setCompoundDrawables(null, tDrawable, null, null);
        }
        ((TextView) v).setTextColor(underlineColor);
    }
}