List of usage examples for android.graphics.drawable Drawable setBounds
public void setBounds(@NonNull Rect bounds)
From source file:com.huewu.pla.lib.internal.PLAListView.java
void drawOverscrollFooter(final Canvas canvas, final Drawable drawable, final Rect bounds) { final int height = drawable.getMinimumHeight(); canvas.save();/* w w w . jav a 2 s.co m*/ 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(); }
From source file:com.huewu.pla.lib.internal.PLAListView.java
void drawOverscrollHeader(final Canvas canvas, final Drawable drawable, final Rect bounds) { final int height = drawable.getMinimumHeight(); canvas.save();//ww w . j ava 2s .co m 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(); }
From source file:com.android.leanlauncher.CellLayout.java
@Override protected void onDraw(Canvas canvas) { // When we're large, we are either drawn in a "hover" state (ie when dragging an item to // a neighboring page) or with just a normal background (if backgroundAlpha > 0.0f) // When we're small, we are either drawn normally or in the "accepts drops" state (during // a drag). However, we also drag the mini hover background *over* one of those two // backgrounds if (mDrawBackground && mBackgroundAlpha > 0.0f) { Drawable bg; if (mUseActiveGlowBackground) { // In the mini case, we draw the active_glow bg *over* the active background bg = mActiveGlowBackground;//w w w. j a v a 2 s . com } else { bg = mNormalBackground; } bg.setAlpha((int) (mBackgroundAlpha * mBackgroundAlphaMultiplier * 255)); bg.setBounds(mBackgroundRect); bg.draw(canvas); } final Paint paint = mDragOutlinePaint; for (int i = 0; i < mDragOutlines.length; i++) { final float alpha = mDragOutlineAlphas[i]; if (alpha > 0) { final Rect r = mDragOutlines[i]; mTempRect.set(r); Utilities.scaleRectAboutCenter(mTempRect, getChildrenScale()); final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag(); paint.setAlpha((int) (alpha + .5f)); canvas.drawBitmap(b, null, mTempRect, paint); } } }
From source file:com.amsterdam.marktbureau.makkelijkemarkt.DagvergunningFragment.java
/** * Set the state of the buttons of the wizard menu depending on the selected tab * @param tabPosition position of the tab */// w ww .jav a 2 s . c o m private void setWizardMenu(int tabPosition) { // button background colors int accentColor = ContextCompat.getColor(getContext(), R.color.accent); int whiteColor = ContextCompat.getColor(getContext(), android.R.color.white); int primaryDarkColor = ContextCompat.getColor(getContext(), R.color.primary_dark); int primaryColor = ContextCompat.getColor(getContext(), R.color.primary); int redColor = ContextCompat.getColor(getContext(), R.color.dagvergunning_melding_background); // button icons Drawable leftDrawable = ContextCompat.getDrawable(getContext(), R.drawable.chevron_left_primary_dark); Drawable trashDrawable = ContextCompat.getDrawable(getContext(), R.drawable.delete_white); Drawable rightDrawable = ContextCompat.getDrawable(getContext(), R.drawable.chevron_right_primary_dark); Drawable checkDrawable = ContextCompat.getDrawable(getContext(), R.drawable.check_primary_dark); // get previous button left drawable bounds Drawable[] previousButtonDrawables = mWizardPreviousButton.getCompoundDrawables(); Drawable previousButtonLeftDrawable = previousButtonDrawables[0]; // get next button right drawable bounds Drawable[] nextButtonDrawables = mWizardNextButton.getCompoundDrawables(); Drawable nextButtonRightDrawable = nextButtonDrawables[2]; switch (tabPosition) { // koopman tab case 0: // previous if (mId == -1) { // new dagvergunning, so hide the delete button mWizardPreviousButton.setVisibility(View.INVISIBLE); mWizardPreviousButton.setBackgroundColor(whiteColor); mWizardPreviousButton.setText(""); mWizardPreviousButton.setTextColor(primaryDarkColor); if (leftDrawable != null) { leftDrawable.setBounds(previousButtonLeftDrawable.getBounds()); mWizardPreviousButton.setCompoundDrawables(leftDrawable, null, null, null); } } else { // existing dagvergunning, so show the delete button mWizardPreviousButton.setVisibility(View.VISIBLE); mWizardPreviousButton.setBackgroundColor(redColor); mWizardPreviousButton.setText(getString(R.string.delete)); mWizardPreviousButton.setTextColor(whiteColor); if (trashDrawable != null) { trashDrawable.setBounds(previousButtonLeftDrawable.getBounds()); mWizardPreviousButton.setCompoundDrawables(trashDrawable, null, null, null); } } // next mWizardNextButton.setVisibility(View.VISIBLE); mWizardNextButton.setBackgroundColor(accentColor); mWizardNextButton.setText(getString(R.string.product)); if (rightDrawable != null) { rightDrawable.setBounds(nextButtonRightDrawable.getBounds()); mWizardNextButton.setCompoundDrawables(null, null, rightDrawable, null); } break; // product tab case 1: // previous mWizardPreviousButton.setVisibility(View.VISIBLE); mWizardPreviousButton.setBackgroundColor(whiteColor); mWizardPreviousButton.setText(getString(R.string.koopman)); mWizardPreviousButton.setTextColor(primaryDarkColor); if (leftDrawable != null) { leftDrawable.setBounds(previousButtonLeftDrawable.getBounds()); mWizardPreviousButton.setCompoundDrawables(leftDrawable, null, null, null); } // next mWizardNextButton.setVisibility(View.VISIBLE); mWizardNextButton.setBackgroundColor(accentColor); mWizardNextButton.setText(getString(R.string.overzicht)); if (rightDrawable != null) { rightDrawable.setBounds(nextButtonRightDrawable.getBounds()); mWizardNextButton.setCompoundDrawables(null, null, rightDrawable, null); } break; // overzicht tab case 2: // previous mWizardPreviousButton.setVisibility(View.VISIBLE); mWizardPreviousButton.setBackgroundColor(whiteColor); mWizardPreviousButton.setText(getString(R.string.product)); mWizardPreviousButton.setTextColor(primaryDarkColor); if (leftDrawable != null) { leftDrawable.setBounds(previousButtonLeftDrawable.getBounds()); mWizardPreviousButton.setCompoundDrawables(leftDrawable, null, null, null); } // next mWizardNextButton.setVisibility(View.VISIBLE); mWizardNextButton.setBackgroundColor(primaryColor); mWizardNextButton.setTextColor(primaryDarkColor); mWizardNextButton.setText(getString(R.string.save)); if (checkDrawable != null) { checkDrawable.setBounds(nextButtonRightDrawable.getBounds()); mWizardNextButton.setCompoundDrawables(null, null, checkDrawable, null); } break; default: break; } }
From source file:org.bangbang.support.v4.widget.HListView.java
/** * Draws a divider for the given child in the given bounds. *//from w w w . ja v a2 s . c om * @param canvas The canvas to draw to. * @param bounds The bounds of the divider. * @param childIndex The index of child (of the View) above the divider. * This will be -1 if there is no child above the divider to be * drawn. */ void drawDivider(Canvas canvas, Rect bounds, int childIndex) { // This widget draws the same divider for all children final Drawable divider = mDivider; final boolean clipDivider = mClipDivider; if (!clipDivider) { divider.setBounds(bounds); } else { canvas.save(); canvas.clipRect(bounds); } divider.draw(canvas); if (clipDivider) { canvas.restore(); } }
From source file:com.appunite.list.HorizontalListView.java
/** * Draws a divider for the given child in the given bounds. * * @param canvas The canvas to draw to./*from w w w .j a v a2s . c o m*/ * @param bounds The bounds of the divider. * @param childIndex The index of child (of the View) above the divider. * This will be -1 if there is no child above the divider to be * drawn. */ void drawDivider(Canvas canvas, Rect bounds, int childIndex) { // This widget draws the same divider for all children final Drawable divider = mDivider; divider.setBounds(bounds); divider.draw(canvas); }
From source file:com.appunite.list.HorizontalListView.java
void drawOverscrollHeader(Canvas canvas, Drawable drawable, Rect bounds) { final int width = drawable.getMinimumWidth(); canvas.save();/*from w w w .j a v a 2 s . c om*/ canvas.clipRect(bounds); final int span = bounds.right - bounds.left; if (span < width) { bounds.left = bounds.right - width; } drawable.setBounds(bounds); drawable.draw(canvas); canvas.restore(); }
From source file:com.appunite.list.HorizontalListView.java
void drawOverscrollFooter(Canvas canvas, Drawable drawable, Rect bounds) { final int width = drawable.getMinimumWidth(); canvas.save();//from w ww. j a v a2 s. c o m canvas.clipRect(bounds); final int span = bounds.right - bounds.left; if (span < width) { bounds.right = bounds.left + width; } drawable.setBounds(bounds); drawable.draw(canvas); canvas.restore(); }
From source file:com.appunite.list.ListView.java
void drawOverscrollHeader(Canvas canvas, Drawable drawable, Rect bounds) { final int height = drawable.getMinimumHeight(); canvas.save();/* w w w . j a va2 s. com*/ 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(); }
From source file:com.appunite.list.ListView.java
void drawOverscrollFooter(Canvas canvas, Drawable drawable, Rect bounds) { final int height = drawable.getMinimumHeight(); canvas.save();/*from ww w . j a v a2 s .c o m*/ 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(); }