Java Code Examples for android.graphics.drawable.ColorDrawable#setBounds()

The following examples show how to use android.graphics.drawable.ColorDrawable#setBounds() . 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: ConfigActivity.java    From J2ME-Loader with Apache License 2.0 5 votes vote down vote up
ColorTextWatcher(EditText editText) {
	this.editText = editText;
	int size = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 32,
			editText.getResources().getDisplayMetrics());
	ColorDrawable colorDrawable = new ColorDrawable();
	colorDrawable.setBounds(0, 0, size, size);
	editText.setCompoundDrawablesRelative(null, null, colorDrawable, null);
	drawable = colorDrawable;
	editText.setFilters(new InputFilter[]{this::filter});
	editText.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
}
 
Example 2
Source File: OnlineImgImpl.java    From chaoli-forum-for-android-2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * show placeholder on attachment images
 * @param builder SpannableStringBuilder in which placeholder shows
 */
private void showPlaceHolder(final SpannableStringBuilder builder) {
    for (Formula formula : mFormulaList) {
        Log.d(TAG, "showPlaceHolder: " + formula.content + ", " + formula.type);
        if (formula.type == Formula.TYPE_ATT || formula.type == Formula.TYPE_IMG) {
            final ColorDrawable colorDrawable = new ColorDrawable(ContextCompat.getColor(((View) mView).getContext(), android.R.color.darker_gray));
            colorDrawable.setBounds(0, 0, 600, 300);
            final ImageSpan imageSpan = new ImageSpan(colorDrawable);
            placeHolders.put(formula, imageSpan);
            builder.setSpan(imageSpan, formula.start, formula.end, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
        }
    }
    mView.setText(builder);
}
 
Example 3
Source File: DefaultImageGetter.java    From Ruisi with Apache License 2.0 5 votes vote down vote up
private Drawable getPlaceHolder(String souce) {
    ColorDrawable colorDrawable = new ColorDrawable(Color.TRANSPARENT);
    if (souce == null || souce.isEmpty()) {
        colorDrawable.setBounds(0, 0, 1, 1);
    } else if (souce.startsWith(SMILEY_PREFIX)) {
        colorDrawable.setBounds(0, 0, smileySize, smileySize);
    } else {
        colorDrawable.setBounds(0, 0, 1, 1);
    }

    return colorDrawable;
}
 
Example 4
Source File: RichTextConfig.java    From RichText with MIT License 5 votes vote down vote up
@Override
public Drawable getDrawable(ImageHolder holder, RichTextConfig config, TextView textView) {
    ColorDrawable drawable = new ColorDrawable(Color.DKGRAY);
    int width = textView.getWidth();
    drawable.setBounds(0, 0, width, width / 2);
    HANDLER.obtainMessage(SET_BOUNDS, Pair.create(drawable, textView)).sendToTarget();
    return drawable;
}
 
Example 5
Source File: RichTextConfig.java    From RichText with MIT License 5 votes vote down vote up
@Override
public Drawable getDrawable(ImageHolder holder, RichTextConfig config, TextView textView) {
    ColorDrawable drawable = new ColorDrawable(Color.LTGRAY);
    int width = textView.getWidth() ;
    drawable.setBounds(0, 0, width, width / 2);
    HANDLER.obtainMessage(SET_BOUNDS, Pair.create(drawable, textView)).sendToTarget();
    return drawable;
}
 
Example 6
Source File: MaterialRippleLayoutNineOld.java    From KickAssSlidingMenu with Apache License 2.0 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 7
Source File: MaterialRippleLayout.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 8
Source File: MaterialRippleLayout.java    From material-ripple with Apache License 2.0 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 9
Source File: MaterialRippleLayout.java    From AdvancedMaterialDrawer with Apache License 2.0 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 10
Source File: MaterialRippleLayoutNineOld.java    From AdvancedMaterialDrawer with Apache License 2.0 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 11
Source File: MaterialRippleLayout.java    From LoyalNativeSlider with MIT License 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 12
Source File: MaterialRippleLayout.java    From KickAssSlidingMenu with Apache License 2.0 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 13
Source File: DividerItemDecoration.java    From CrawlerForReader with Apache License 2.0 4 votes vote down vote up
public DividerItemDecoration(int orientation, boolean showLastLine) {
    this.showLastLine = showLastLine;
    mDivider = new ColorDrawable(0xffd3d3d3);
    mDivider.setBounds(0, 0, ScreenUtils.getScreenWidth(), 1);
    setOrientation(orientation);
}
 
Example 14
Source File: RippleLayout.java    From fingerpoetry-android with Apache License 2.0 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 15
Source File: MaterialRippleLayout.java    From talk-android with MIT License 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 16
Source File: MaterialRippleLayout.java    From MDPreference with Apache License 2.0 4 votes vote down vote up
public void setRippleBackground(int color) {
    rippleBackground = new ColorDrawable(color);
    rippleBackground.setBounds(bounds);
    invalidate();
}
 
Example 17
Source File: CellLayout.java    From LaunchEnr with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onDraw(Canvas canvas) {
    if (!mIsDragTarget) {
        return;
    }

    // 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 (mBackgroundAlpha > 0.0f) {
        mBackground.draw(canvas);
    }

    final Paint paint = mDragOutlinePaint;
    for (int i = 0; i < mDragOutlines.length; i++) {
        final float alpha = mDragOutlineAlphas[i];
        if (alpha > 0) {
            final Bitmap b = (Bitmap) mDragOutlineAnims[i].getTag();
            paint.setAlpha((int)(alpha + .5f));
            canvas.drawBitmap(b, null, mDragOutlines[i], paint);
        }
    }

    if (DEBUG_VISUALIZE_OCCUPIED) {
        int[] pt = new int[2];
        ColorDrawable cd = new ColorDrawable(Color.RED);
        cd.setBounds(0, 0,  mCellWidth, mCellHeight);
        for (int i = 0; i < mCountX; i++) {
            for (int j = 0; j < mCountY; j++) {
                if (mOccupied.cells[i][j]) {
                    cellToPoint(i, j, pt);
                    canvas.save();
                    canvas.translate(pt[0], pt[1]);
                    cd.draw(canvas);
                    canvas.restore();
                }
            }
        }
    }

    for (int i = 0; i < mFolderBackgrounds.size(); i++) {
        FolderIcon.PreviewBackground bg = mFolderBackgrounds.get(i);
        cellToPoint(bg.delegateCellX, bg.delegateCellY, mTempLocation);
        canvas.save();
        canvas.translate(mTempLocation[0], mTempLocation[1]);
        bg.drawBackground(mLauncher, canvas);
        if (!bg.isClipping) {
            bg.drawBackgroundStroke(mLauncher, canvas);
        }
        canvas.restore();
    }

    if (mFolderLeaveBehind.delegateCellX >= 0 && mFolderLeaveBehind.delegateCellY >= 0) {
        cellToPoint(mFolderLeaveBehind.delegateCellX,
                mFolderLeaveBehind.delegateCellY, mTempLocation);
        canvas.save();
        canvas.translate(mTempLocation[0], mTempLocation[1]);
        mFolderLeaveBehind.drawLeaveBehind(canvas);
        canvas.restore();
    }
}