Java Code Examples for android.graphics.drawable.Drawable#getMinimumHeight()
The following examples show how to use
android.graphics.drawable.Drawable#getMinimumHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ListView.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
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(); }
Example 2
Source File: PLAListView.java From SimplifyReader with Apache License 2.0 | 6 votes |
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(); }
Example 3
Source File: GestureImageView.java From ViewPagerTabIndicator with Artistic License 2.0 | 6 votes |
@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(); }
Example 4
Source File: UtilMoreText.java From AndroidAnimationExercise with Apache License 2.0 | 6 votes |
/** * 设置富文本 图片 * * @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; }
Example 5
Source File: PLAListView.java From Lay-s with MIT License | 6 votes |
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(); }
Example 6
Source File: PXButtonDrawable.java From pixate-freestyle-android with Apache License 2.0 | 6 votes |
/** * 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); } }
Example 7
Source File: PLA_ListView.java From EverMemo with MIT License | 6 votes |
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(); }
Example 8
Source File: SelectDrawableAdapter.java From LoopBanner with Apache License 2.0 | 6 votes |
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; }
Example 9
Source File: ListView.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
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(); }
Example 10
Source File: GAccount.java From GoogleNavigationDrawer with Apache License 2.0 | 5 votes |
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; }
Example 11
Source File: IcsProgressBar.java From CSipSimple with GNU General Public License v3.0 | 5 votes |
/** * <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); } }
Example 12
Source File: IcsProgressBar.java From zhangshangwuda with Apache License 2.0 | 5 votes |
/** * <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); } }
Example 13
Source File: GridDrawable.java From ProjectX with Apache License 2.0 | 5 votes |
@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)); }
Example 14
Source File: PhotoView.java From SprintNBA with Apache License 2.0 | 5 votes |
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; }
Example 15
Source File: MultiSlider.java From MultiSlider with Apache License 2.0 | 5 votes |
/** * 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 } }
Example 16
Source File: IcsProgressBar.java From zen4android with MIT License | 5 votes |
/** * <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); } }
Example 17
Source File: IcsProgressBar.java From Libraries-for-Android-Developers with MIT License | 5 votes |
/** * <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); } }
Example 18
Source File: CropImageView.java From YImagePicker with Apache License 2.0 | 4 votes |
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); }
Example 19
Source File: LockscreenAppBar.java From GravityBox with Apache License 2.0 | 4 votes |
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); }
Example 20
Source File: PhotoView.java From SprintNBA with Apache License 2.0 | 4 votes |
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; }