android.graphics.drawable.Drawable#getMinimumHeight()源码实例Demo

下面列出了android.graphics.drawable.Drawable#getMinimumHeight() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: android_9.0.0_r45   文件: ListView.java
void drawOverscrollHeader(Canvas canvas, Drawable drawable, Rect bounds) {
    final int height = drawable.getMinimumHeight();

    canvas.save();
    canvas.clipRect(bounds);

    final int span = bounds.bottom - bounds.top;
    if (span < height) {
        bounds.top = bounds.bottom - height;
    }

    drawable.setBounds(bounds);
    drawable.draw(canvas);

    canvas.restore();
}
 
源代码2 项目: android_9.0.0_r45   文件: ListView.java
void drawOverscrollFooter(Canvas canvas, Drawable drawable, Rect bounds) {
    final int height = drawable.getMinimumHeight();

    canvas.save();
    canvas.clipRect(bounds);

    final int span = bounds.bottom - bounds.top;
    if (span < height) {
        bounds.bottom = bounds.top + height;
    }

    drawable.setBounds(bounds);
    drawable.draw(canvas);

    canvas.restore();
}
 
源代码3 项目: LoopBanner   文件: SelectDrawableAdapter.java
private LinearLayout.LayoutParams generateLayoutParams(Drawable drawable, int size, int margin) {
    if (mLayoutParams == null) {
        final int minimumWidth = drawable.getMinimumWidth();
        final int minimumHeight = drawable.getMinimumHeight();
        LinearLayout.LayoutParams layoutParams;
        if (minimumWidth == 0 || minimumHeight == 0) {
            layoutParams = new LinearLayout.LayoutParams(size, size);
        } else {
            layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
                    LinearLayout.LayoutParams.WRAP_CONTENT);
        }
        layoutParams.leftMargin = margin;
        mLayoutParams = layoutParams;
    }
    return mLayoutParams;
}
 
源代码4 项目: EverMemo   文件: PLA_ListView.java
void drawOverscrollFooter(Canvas canvas, Drawable drawable, Rect bounds) {
	final int height = drawable.getMinimumHeight();

	canvas.save();
	canvas.clipRect(bounds);

	final int span = bounds.bottom - bounds.top;
	if (span < height) {
		bounds.bottom = bounds.top + height;
	}

	drawable.setBounds(bounds);
	drawable.draw(canvas);

	canvas.restore();
}
 
/**
 * Set tint color on a given {@link Button}. This method will set an
 * instance of this {@link PXButtonDrawable} as the {@link Button}s
 * background drawable.
 * 
 * @param button A {@link Button}. In case the button does not have a
 *            {@link PXButtonDrawable} as a background, this method will
 *            attach one and theme it.
 * @param color
 */
@SuppressWarnings("deprecation")
public static void setTintColor(Button button, int color) {
    Drawable drawable = button.getBackground();
    if (drawable instanceof PXButtonDrawable) {
        setTintColor(button, (PXButtonDrawable) drawable, color);
    } else {
        Drawable prevDrawable = button.getBackground();
        PXButtonDrawable pxDrawable;
        if (prevDrawable != null) {
            pxDrawable = new PXButtonDrawable(prevDrawable.getMinimumHeight(),
                    prevDrawable.getMinimumWidth());
        } else {
            // TODO: API 16 supports getMinimunHeight and getMinimumWidth
            pxDrawable = new PXButtonDrawable(button.getHeight(), button.getWidth());
        }
        button.setBackgroundDrawable(pxDrawable);
        setTintColor(button, pxDrawable, color);
    }
}
 
源代码6 项目: Lay-s   文件: PLAListView.java
void drawOverscrollHeader(Canvas canvas, Drawable drawable, Rect bounds) {
    final int height = drawable.getMinimumHeight();

    canvas.save();
    canvas.clipRect(bounds);

    final int span = bounds.bottom - bounds.top;
    if (span < height) {
        bounds.top = bounds.bottom - height;
    }

    drawable.setBounds(bounds);
    drawable.draw(canvas);

    canvas.restore();
}
 
源代码7 项目: AndroidAnimationExercise   文件: UtilMoreText.java
/**
 * 设置富文本 图片
 *
 * @param text     文字
 * @param drawable 图片
 * @return SpannableString
 */
private SpannableString getSpannableImg(CharSequence text, Drawable drawable) {
    int len = text.length();
    if (len == 0 || len < 5) {
        text = "请输入要展示的信息!";
        return new SpannableString(text);
    }
    SpannableString spanableInfo = new SpannableString(text);
    int drawHeight = drawable.getMinimumHeight();
    drawable.setBounds(0, 0, drawHeight, drawHeight);
    CenterAlignImageSpan imageSpan = new CenterAlignImageSpan(drawable);
    spanableInfo.setSpan(imageSpan, len - 2, len, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
    spanableInfo.setSpan(new spanImgClickable(), text.length() - 2, text.length(),
            Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
    return spanableInfo;
}
 
源代码8 项目: ViewPagerTabIndicator   文件: GestureImageView.java
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
    int width = MeasureSpec.getSize(widthMeasureSpec);
    int height = MeasureSpec.getSize(heightMeasureSpec);
    viewSize = new PointF(width, height);

    //��ȡ��ǰDrawable�Ĵ�С
    Drawable drawable = getDrawable();
    if (drawable == null) {
        Log.e("no drawable", "drawable is nullPtr");
    } else {
        imageSize = new PointF(drawable.getMinimumWidth(), drawable.getMinimumHeight());
    }

    FitCenter();
}
 
源代码9 项目: SimplifyReader   文件: PLAListView.java
void drawOverscrollHeader(Canvas canvas, Drawable drawable, Rect bounds) {
    final int height = drawable.getMinimumHeight();

    canvas.save();
    canvas.clipRect(bounds);

    final int span = bounds.bottom - bounds.top;
    if (span < height) {
        bounds.top = bounds.bottom - height;
    }

    drawable.setBounds(bounds);
    drawable.draw(canvas);

    canvas.restore();
}
 
源代码10 项目: MultiSlider   文件: MultiSlider.java
/**
     * Manually set the track drawable
     *
     * @param d
     */
    public void setTrackDrawable(Drawable d) {
        boolean needUpdate;
        if (mTrack != null && d != mTrack) {
            mTrack.setCallback(null);
            needUpdate = true;
        } else {
            needUpdate = false;
        }

        if (d != null) {
            d.setCallback(this);
//            if (canResolveLayoutDirection()) {
//                d.setLayoutDirection(getLayoutDirection());
//            }

            // Make sure the ProgressBar is always tall enough
            int drawableHeight = d.getMinimumHeight();
            if (mMaxHeight < drawableHeight) {
                mMaxHeight = drawableHeight;
                requestLayout();
            }
        }
        mTrack = d;

        if (needUpdate) {
            updateTrackBounds(getWidth(), getHeight());
            updateTrackState();
            //TODO update all thumbs with their range tracks also
        }
    }
 
源代码11 项目: zhangshangwuda   文件: IcsProgressBar.java
/**
 * <p>Define the drawable used to draw the progress bar in
 * progress mode.</p>
 *
 * @param d the new drawable
 *
 * @see #getProgressDrawable()
 * @see #setIndeterminate(boolean)
 */
public void setProgressDrawable(Drawable d) {
    boolean needUpdate;
    if (mProgressDrawable != null && d != mProgressDrawable) {
        mProgressDrawable.setCallback(null);
        needUpdate = true;
    } else {
        needUpdate = false;
    }

    if (d != null) {
        d.setCallback(this);

        // Make sure the ProgressBar is always tall enough
        int drawableHeight = d.getMinimumHeight();
        if (mMaxHeight < drawableHeight) {
            mMaxHeight = drawableHeight;
            requestLayout();
        }
    }
    mProgressDrawable = d;
    if (!mIndeterminate) {
        mCurrentDrawable = d;
        postInvalidate();
    }

    if (needUpdate) {
        updateDrawableBounds(getWidth(), getHeight());
        updateDrawableState();
        doRefreshProgress(android.R.id.progress, mProgress, false, false);
        doRefreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false, false);
    }
}
 
源代码12 项目: GoogleNavigationDrawer   文件: GAccount.java
private Bitmap convertToBitmap(Drawable drawable) {
    Bitmap mutableBitmap;
    if(drawable.getMinimumHeight() == 0 || drawable.getMinimumWidth() == 0)
        mutableBitmap = Bitmap.createBitmap(100, 100, Bitmap.Config.ARGB_8888);
    else
        mutableBitmap = Bitmap.createBitmap(drawable.getMinimumWidth(), drawable.getMinimumHeight(), Bitmap.Config.ARGB_8888);
    Canvas canvas = new Canvas(mutableBitmap);
    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
    drawable.draw(canvas);

    return mutableBitmap;
}
 
源代码13 项目: CSipSimple   文件: IcsProgressBar.java
/**
 * <p>Define the drawable used to draw the progress bar in
 * progress mode.</p>
 *
 * @param d the new drawable
 *
 * @see #getProgressDrawable()
 * @see #setIndeterminate(boolean)
 */
public void setProgressDrawable(Drawable d) {
    boolean needUpdate;
    if (mProgressDrawable != null && d != mProgressDrawable) {
        mProgressDrawable.setCallback(null);
        needUpdate = true;
    } else {
        needUpdate = false;
    }

    if (d != null) {
        d.setCallback(this);

        // Make sure the ProgressBar is always tall enough
        int drawableHeight = d.getMinimumHeight();
        if (mMaxHeight < drawableHeight) {
            mMaxHeight = drawableHeight;
            requestLayout();
        }
    }
    mProgressDrawable = d;
    if (!mIndeterminate) {
        mCurrentDrawable = d;
        postInvalidate();
    }

    if (needUpdate) {
        updateDrawableBounds(getWidth(), getHeight());
        updateDrawableState();
        doRefreshProgress(android.R.id.progress, mProgress, false, false);
        doRefreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false, false);
    }
}
 
源代码14 项目: ProjectX   文件: GridDrawable.java
@Override
public int getMinimumHeight() {
    if (mRowCount <= 0)
        return -1;
    final Drawable drawable = getWrappedDrawable();
    if (drawable == null)
        return -1;
    final int itemHeight = drawable.getMinimumHeight();
    return Math.round(mRowCount * itemHeight + mVerticalSpacing * (mRowCount - 1));
}
 
源代码15 项目: SprintNBA   文件: PhotoView.java
private boolean hasSize(Drawable d) {
    if ((d.getIntrinsicHeight() <= 0 || d.getIntrinsicWidth() <= 0)
            && (d.getMinimumWidth() <= 0 || d.getMinimumHeight() <= 0)
            && (d.getBounds().width() <= 0 || d.getBounds().height() <= 0)) {
        return false;
    }
    return true;
}
 
源代码16 项目: zen4android   文件: IcsProgressBar.java
/**
 * <p>Define the drawable used to draw the progress bar in
 * progress mode.</p>
 *
 * @param d the new drawable
 *
 * @see #getProgressDrawable()
 * @see #setIndeterminate(boolean)
 */
public void setProgressDrawable(Drawable d) {
    boolean needUpdate;
    if (mProgressDrawable != null && d != mProgressDrawable) {
        mProgressDrawable.setCallback(null);
        needUpdate = true;
    } else {
        needUpdate = false;
    }

    if (d != null) {
        d.setCallback(this);

        // Make sure the ProgressBar is always tall enough
        int drawableHeight = d.getMinimumHeight();
        if (mMaxHeight < drawableHeight) {
            mMaxHeight = drawableHeight;
            requestLayout();
        }
    }
    mProgressDrawable = d;
    if (!mIndeterminate) {
        mCurrentDrawable = d;
        postInvalidate();
    }

    if (needUpdate) {
        updateDrawableBounds(getWidth(), getHeight());
        updateDrawableState();
        doRefreshProgress(android.R.id.progress, mProgress, false, false);
        doRefreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false, false);
    }
}
 
/**
 * <p>Define the drawable used to draw the progress bar in
 * progress mode.</p>
 *
 * @param d the new drawable
 *
 * @see #getProgressDrawable()
 * @see #setIndeterminate(boolean)
 */
public void setProgressDrawable(Drawable d) {
    boolean needUpdate;
    if (mProgressDrawable != null && d != mProgressDrawable) {
        mProgressDrawable.setCallback(null);
        needUpdate = true;
    } else {
        needUpdate = false;
    }

    if (d != null) {
        d.setCallback(this);

        // Make sure the ProgressBar is always tall enough
        int drawableHeight = d.getMinimumHeight();
        if (mMaxHeight < drawableHeight) {
            mMaxHeight = drawableHeight;
            requestLayout();
        }
    }
    mProgressDrawable = d;
    if (!mIndeterminate) {
        mCurrentDrawable = d;
        postInvalidate();
    }

    if (needUpdate) {
        updateDrawableBounds(getWidth(), getHeight());
        updateDrawableState();
        doRefreshProgress(android.R.id.progress, mProgress, false, false);
        doRefreshProgress(android.R.id.secondaryProgress, mSecondaryProgress, false, false);
    }
}
 
源代码18 项目: YImagePicker   文件: CropImageView.java
private boolean hasSize(Drawable d) {
    return (d.getIntrinsicHeight() > 0 && d.getIntrinsicWidth() > 0)
            || (d.getMinimumWidth() > 0 && d.getMinimumHeight() > 0)
            || (d.getBounds().width() > 0 && d.getBounds().height() > 0);
}
 
源代码19 项目: GravityBox   文件: LockscreenAppBar.java
private Drawable createBadgeDrawable(Drawable d, int count) {
    if (d == null) return null;

    NumberFormat f = NumberFormat.getIntegerInstance();
    String countStr = count > 99 ? "99+" : f.format(count);

    Bitmap b = Utils.drawableToBitmap(d);
    b = b.copy(Bitmap.Config.ARGB_8888, true);
    Canvas c = new Canvas(b);

    Paint p = new Paint();
    p.setTextAlign(Paint.Align.CENTER);
    p.setColor(Color.WHITE);
    p.setAntiAlias(true);
    p.setTextSize(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 10,
            mResources.getDisplayMetrics()));

    Drawable bg = mGbResources.getDrawable(R.drawable.ic_notification_overlay, null);

    final int w = b.getWidth();
    final int h = b.getHeight();
    final Rect r = new Rect();
    p.getTextBounds(countStr, 0, countStr.length(), r);
    final int tw = r.right - r.left;
    final int th = r.bottom - r.top;
    bg.getPadding(r);
    int dw = r.left + tw + r.right;
    if (dw < bg.getMinimumWidth()) {
        dw = bg.getMinimumWidth();
    }
    int x = w-r.right-((dw-r.right-r.left)/2);
    int dh = r.top + th + r.bottom;
    if (dh < bg.getMinimumHeight()) {
        dh = bg.getMinimumHeight();
    }
    if (dw < dh) dw = dh;
    int y = h-r.bottom-((dh-r.top-th-r.bottom)/2);
    bg.setBounds(w-dw, h-dh, w, h);

    bg.draw(c);
    c.drawText(countStr, x, y, p);

    return new BitmapDrawable(mResources, b);
}
 
源代码20 项目: SprintNBA   文件: PhotoView.java
private static int getDrawableHeight(Drawable d) {
    int height = d.getIntrinsicHeight();
    if (height <= 0) height = d.getMinimumHeight();
    if (height <= 0) height = d.getBounds().height();
    return height;
}