Java Code Examples for android.graphics.drawable.ShapeDrawable#setIntrinsicHeight()

The following examples show how to use android.graphics.drawable.ShapeDrawable#setIntrinsicHeight() . 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: ColorPickerAdapter.java    From indigenous-android with GNU General Public License v3.0 6 votes vote down vote up
private void buildColorPickerView(View view, int colorCode) {
    view.setVisibility(View.VISIBLE);

    ShapeDrawable biggerCircle = new ShapeDrawable(new OvalShape());
    biggerCircle.setIntrinsicHeight(20);
    biggerCircle.setIntrinsicWidth(20);
    biggerCircle.setBounds(new Rect(0, 0, 20, 20));
    biggerCircle.getPaint().setColor(colorCode);

    ShapeDrawable smallerCircle = new ShapeDrawable(new OvalShape());
    smallerCircle.setIntrinsicHeight(5);
    smallerCircle.setIntrinsicWidth(5);
    smallerCircle.setBounds(new Rect(0, 0, 5, 5));
    smallerCircle.getPaint().setColor(Color.WHITE);
    smallerCircle.setPadding(10, 10, 10, 10);
    Drawable[] drawables = {smallerCircle, biggerCircle};

    LayerDrawable layerDrawable = new LayerDrawable(drawables);

    view.setBackgroundDrawable(layerDrawable);
}
 
Example 2
Source File: ColorPickerAdapter.java    From PhotoEditor with MIT License 6 votes vote down vote up
private void buildColorPickerView(View view, int colorCode) {
    view.setVisibility(View.VISIBLE);

    ShapeDrawable biggerCircle = new ShapeDrawable(new OvalShape());
    biggerCircle.setIntrinsicHeight(20);
    biggerCircle.setIntrinsicWidth(20);
    biggerCircle.setBounds(new Rect(0, 0, 20, 20));
    biggerCircle.getPaint().setColor(colorCode);

    ShapeDrawable smallerCircle = new ShapeDrawable(new OvalShape());
    smallerCircle.setIntrinsicHeight(5);
    smallerCircle.setIntrinsicWidth(5);
    smallerCircle.setBounds(new Rect(0, 0, 5, 5));
    smallerCircle.getPaint().setColor(Color.WHITE);
    smallerCircle.setPadding(10, 10, 10, 10);
    Drawable[] drawables = {smallerCircle, biggerCircle};

    LayerDrawable layerDrawable = new LayerDrawable(drawables);

    view.setBackgroundDrawable(layerDrawable);
}
 
Example 3
Source File: ColorPickerAdapter.java    From photo-editor-android with MIT License 6 votes vote down vote up
private void buildColorPickerView(View view, int colorCode) {
    view.setVisibility(View.VISIBLE);

    ShapeDrawable biggerCircle = new ShapeDrawable(new OvalShape());
    biggerCircle.setIntrinsicHeight(20);
    biggerCircle.setIntrinsicWidth(20);
    biggerCircle.setBounds(new Rect(0, 0, 20, 20));
    biggerCircle.getPaint().setColor(colorCode);

    ShapeDrawable smallerCircle = new ShapeDrawable(new OvalShape());
    smallerCircle.setIntrinsicHeight(5);
    smallerCircle.setIntrinsicWidth(5);
    smallerCircle.setBounds(new Rect(0, 0, 5, 5));
    smallerCircle.getPaint().setColor(Color.WHITE);
    smallerCircle.setPadding(10, 10, 10, 10);
    Drawable[] drawables = {smallerCircle, biggerCircle};

    LayerDrawable layerDrawable = new LayerDrawable(drawables);

    view.setBackgroundDrawable(layerDrawable);
}
 
Example 4
Source File: MetronomeFragment.java    From semitone with GNU General Public License v3.0 5 votes vote down vote up
private ShapeDrawable makeDot(int size, int color) {
    ShapeDrawable dot = new ShapeDrawable(new OvalShape());
    dot.setIntrinsicWidth(size);
    dot.setIntrinsicHeight(size);
    dot.getPaint().setColor(ContextCompat.getColor(getContext(), color));
    return dot;
}
 
Example 5
Source File: CropImageView.java    From CropImageView with MIT License 5 votes vote down vote up
private Drawable getCircleDrawable(int color, int width, int height) {
       ShapeDrawable biggerCircle= new ShapeDrawable( new OvalShape());
       biggerCircle.setIntrinsicWidth( width);
       biggerCircle.setIntrinsicHeight( height );
       biggerCircle.setBounds(new Rect(0, 0, width, height));
       biggerCircle.getPaint().setColor(color);
       
       return biggerCircle;
}
 
Example 6
Source File: PointView.java    From AdPlayBanner with Apache License 2.0 5 votes vote down vote up
private void change() {
    float[] outerR = new float[]{mSize / 2, mSize / 2, mSize / 2, mSize / 2, mSize / 2, mSize / 2, mSize / 2, mSize / 2};
    Shape shape = new RoundRectShape(outerR, null, null);
    ShapeDrawable shapeDrawable = new ShapeDrawable(shape);
    shapeDrawable.setIntrinsicHeight((int) mSize);
    shapeDrawable.setIntrinsicWidth((int) mSize);
    shapeDrawable.setPadding(0, 0, 0, 0);
    shapeDrawable.getPaint().setColor(mColor);
    shapeDrawable.getPaint().setStyle(Paint.Style.FILL);
    setBackgroundDrawable(shapeDrawable);
    setHeight((int) mSize);
    setMinWidth((int) mSize);
}
 
Example 7
Source File: CustomScrollerViewProvider.java    From recycler-fast-scroll with Apache License 2.0 5 votes vote down vote up
private static ShapeDrawable drawCircle (int width, int height, int color) {
    ShapeDrawable oval = new ShapeDrawable (new OvalShape());
    oval.setIntrinsicHeight(height);
    oval.setIntrinsicWidth(width);
    oval.getPaint().setColor(color);
    return oval;
}
 
Example 8
Source File: OtherTaskFragment.java    From Conquer with Apache License 2.0 5 votes vote down vote up
private static ShapeDrawable createRectShape(int width, int height, int color) {
    ShapeDrawable shape = new ShapeDrawable(new RectShape());
    shape.setIntrinsicHeight(height);
    shape.setIntrinsicWidth(width);
    shape.getPaint().setColor(color);
    return shape;
}
 
Example 9
Source File: BadgeCircle.java    From BottomBar with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new circle for the Badge background.
 *
 * @param size  the width and height for the circle
 * @param color the activeIconColor for the circle
 * @return a nice and adorable circle.
 */
@NonNull
static ShapeDrawable make(@IntRange(from = 0) int size, @ColorInt int color) {
    ShapeDrawable indicator = new ShapeDrawable(new OvalShape());
    indicator.setIntrinsicWidth(size);
    indicator.setIntrinsicHeight(size);
    indicator.getPaint().setColor(color);
    return indicator;
}
 
Example 10
Source File: Indicator.java    From SwipeSelector with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new ShapeDrawable, in this case a circle.
 * @param size the width and height for the circle
 * @param color the color resource for the circle
 * @return a nice and adorable tiny little circle indicator.
 */
protected static ShapeDrawable newOne(int size, int color) {
    ShapeDrawable indicator = new ShapeDrawable(new OvalShape());
    indicator.setIntrinsicWidth(size);
    indicator.setIntrinsicHeight(size);
    indicator.getPaint().setColor(color);
    return indicator;
}
 
Example 11
Source File: FlavorRecyclerAdapter.java    From Scoops with Apache License 2.0 5 votes vote down vote up
ShapeDrawable generateDrawable(@ColorInt int color){
    ShapeDrawable d = new ShapeDrawable(new OvalShape());
    d.setIntrinsicWidth(Utils.dipToPx(itemView.getContext(), 24));
    d.setIntrinsicHeight(Utils.dipToPx(itemView.getContext(), 24));
    d.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
    return d;
}
 
Example 12
Source File: Dot.java    From SlidingIntroScreen with Apache License 2.0 5 votes vote down vote up
/**
 * Recreates the UI to reflect the current values of the member variables.
 */
private void reflectParametersInView() {
	// Reset root View so that the UI can be entirely recreated
	removeAllViews();

	// Make the root View bounds big enough to encompass the maximum diameter
	final int maxDimension = Math.max(inactiveDiameterPx, activeDiameterPx);
	setLayoutParams(new LayoutParams(maxDimension, maxDimension));

	// Set the gravity to centre for simplicity
	setGravity(Gravity.CENTER);

	// Create the drawable based on the current member variables
	final int diameter = (state == State.ACTIVE) ? activeDiameterPx : inactiveDiameterPx;
	final int color = (state == State.ACTIVE) ? activeColor : inactiveColor;
	shape = new ShapeDrawable(new OvalShape());
	shape.setIntrinsicWidth(diameter);
	shape.setIntrinsicHeight(diameter);
	shape.getPaint().setColor(color);

	// Add the drawable to the drawable holder
	drawableHolder = new ImageView(getContext());
	drawableHolder.setImageDrawable(null); // Forces redraw
	drawableHolder.setImageDrawable(shape);

	// Add the drawable holder to root View
	addView(drawableHolder);
}
 
Example 13
Source File: NotesLayer.java    From geopaparazzi with GNU General Public License v3.0 5 votes vote down vote up
private static MarkerSymbol getMarkerSymbol(GPMapView mapView) {
    SharedPreferences peferences = PreferenceManager.getDefaultSharedPreferences(mapView.getContext());
    // notes type
    boolean doCustom = peferences.getBoolean(LibraryConstants.PREFS_KEY_NOTES_CHECK, true);
    String textSizeStr = peferences.getString(LibraryConstants.PREFS_KEY_NOTES_TEXT_SIZE, LibraryConstants.DEFAULT_NOTES_SIZE + ""); //$NON-NLS-1$
    textSize = Integer.parseInt(textSizeStr);
    colorStr = peferences.getString(LibraryConstants.PREFS_KEY_NOTES_CUSTOMCOLOR, ColorUtilities.ALMOST_BLACK.getHex());
    Drawable notesDrawable;
    if (doCustom) {
        String opacityStr = peferences.getString(LibraryConstants.PREFS_KEY_NOTES_OPACITY, "255"); //$NON-NLS-1$
        String sizeStr = peferences.getString(LibraryConstants.PREFS_KEY_NOTES_SIZE, LibraryConstants.DEFAULT_NOTES_SIZE + ""); //$NON-NLS-1$
        int noteSize = Integer.parseInt(sizeStr);
        float opacity = Integer.parseInt(opacityStr);

        OvalShape notesShape = new OvalShape();
        android.graphics.Paint notesPaint = new android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG);
        notesPaint.setStyle(android.graphics.Paint.Style.FILL);
        notesPaint.setColor(ColorUtilities.toColor(colorStr));
        notesPaint.setAlpha((int) opacity);

        ShapeDrawable notesShapeDrawable = new ShapeDrawable(notesShape);
        android.graphics.Paint paint = notesShapeDrawable.getPaint();
        paint.set(notesPaint);
        notesShapeDrawable.setIntrinsicHeight(noteSize);
        notesShapeDrawable.setIntrinsicWidth(noteSize);
        notesDrawable = notesShapeDrawable;
    } else {
        notesDrawable = Compat.getDrawable(mapView.getContext(), eu.geopaparazzi.library.R.drawable.ic_place_accent_24dp);
    }

    notesBitmap = AndroidGraphics.drawableToBitmap(notesDrawable);

    return new MarkerSymbol(notesBitmap, MarkerSymbol.HotspotPlace.CENTER, false);
}
 
Example 14
Source File: ShapeDrawActivity.java    From coursera-android with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	int width = (int) getResources().getDimension(R.dimen.image_width);
	int height = (int) getResources().getDimension(R.dimen.image_height);
	int padding = (int) getResources().getDimension(R.dimen.padding);

	// Get container View
	RelativeLayout rl = (RelativeLayout) findViewById(R.id.main_window);

	// Create Cyan Shape
	ShapeDrawable cyanShape = new ShapeDrawable(new OvalShape());
	cyanShape.getPaint().setColor(Color.CYAN);
	cyanShape.setIntrinsicHeight(height);
	cyanShape.setIntrinsicWidth(width);
	cyanShape.setAlpha(alpha);

	// Put Cyan Shape into an ImageView
	ImageView cyanView = new ImageView(getApplicationContext());
	cyanView.setImageDrawable(cyanShape);
	cyanView.setPadding(padding, padding, padding, padding);

	// Specify placement of ImageView within RelativeLayout
	RelativeLayout.LayoutParams cyanViewLayoutParams = new RelativeLayout.LayoutParams(
			height, width);
	cyanViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
	cyanViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	cyanView.setLayoutParams(cyanViewLayoutParams);
	rl.addView(cyanView);

	// Create Magenta Shape
	ShapeDrawable magentaShape = new ShapeDrawable(new OvalShape());
	magentaShape.getPaint().setColor(Color.MAGENTA);
	magentaShape.setIntrinsicHeight(height);
	magentaShape.setIntrinsicWidth(width);
	magentaShape.setAlpha(alpha);

	// Put Magenta Shape into an ImageView
	ImageView magentaView = new ImageView(getApplicationContext());
	magentaView.setImageDrawable(magentaShape);
	magentaView.setPadding(padding, padding, padding, padding);

	// Specify placement of ImageView within RelativeLayout
	RelativeLayout.LayoutParams magentaViewLayoutParams = new RelativeLayout.LayoutParams(
			height, width);
	magentaViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
	magentaViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

	magentaView.setLayoutParams(magentaViewLayoutParams);

	rl.addView(magentaView);

}
 
Example 15
Source File: ThumbnailRadioButton.java    From renderscript-samples with Apache License 2.0 4 votes vote down vote up
public void setThumbnail(Bitmap bitmap) {
    // Bitmap drawable
    BitmapDrawable bmp = new BitmapDrawable(getResources(), bitmap);
    bmp.setGravity(Gravity.CENTER);

    int strokeWidth = 24;
    // Checked state
    ShapeDrawable rectChecked = new ShapeDrawable(new RectShape());
    rectChecked.getPaint().setColor(0xFFFFFFFF);
    rectChecked.getPaint().setStyle(Paint.Style.STROKE);
    rectChecked.getPaint().setStrokeWidth(strokeWidth);
    rectChecked.setIntrinsicWidth(bitmap.getWidth() + strokeWidth);
    rectChecked.setIntrinsicHeight(bitmap.getHeight() + strokeWidth);
    Drawable drawableArray[] = new Drawable[]{bmp, rectChecked};
    LayerDrawable layerChecked = new LayerDrawable(drawableArray);

    // Unchecked state
    ShapeDrawable rectUnchecked = new ShapeDrawable(new RectShape());
    rectUnchecked.getPaint().setColor(0x0);
    rectUnchecked.getPaint().setStyle(Paint.Style.STROKE);
    rectUnchecked.getPaint().setStrokeWidth(strokeWidth);
    rectUnchecked.setIntrinsicWidth(bitmap.getWidth() + strokeWidth);
    rectUnchecked.setIntrinsicHeight(bitmap.getHeight() + strokeWidth);
    Drawable drawableArray2[] = new Drawable[]{bmp, rectUnchecked};
    LayerDrawable layerUnchecked = new LayerDrawable(drawableArray2);

    // StateList drawable
    StateListDrawable states = new StateListDrawable();
    states.addState(new int[]{android.R.attr.state_checked},
            layerChecked);
    states.addState(new int[]{},
            layerUnchecked);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        setBackground(states);
    } else {
        //noinspection deprecation
        setBackgroundDrawable(states);
    }

    //Offset text to center/bottom of the checkbox
    Paint paint = new Paint();
    paint.setAntiAlias(true);
    paint.setTextSize(getTextSize());
    paint.setTypeface(getTypeface());
    float w = paint.measureText(getText(), 0, getText().length());
    setPadding(getPaddingLeft() + (int) ((bitmap.getWidth() - w) / 2.f + .5f),
            getPaddingTop() + (int) (bitmap.getHeight() * 0.70),
            getPaddingRight(),
            getPaddingBottom());

    setShadowLayer(5, 0, 0, Color.BLACK);
}
 
Example 16
Source File: FlatToggleButton.java    From GreenDamFileExploere with Apache License 2.0 4 votes vote down vote up
private void init(AttributeSet attrs) {

        if (attributes == null)
            attributes = new Attributes(this, getResources());

        if (attrs != null) {
            TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.fl_FlatToggleButton);

            // getting common attributes
            int customTheme = a.getResourceId(R.styleable.fl_FlatToggleButton_fl_theme, Attributes.DEFAULT_THEME);
            attributes.setThemeSilent(customTheme, getResources());

            attributes.setRadius(a.getDimensionPixelSize(R.styleable.fl_FlatToggleButton_fl_cornerRadius, Attributes.DEFAULT_RADIUS_PX));

            space = a.getDimensionPixelSize(R.styleable.fl_FlatToggleButton_fl_space, space);
            padding = space / 10;

            a.recycle();
        }

        // creating unchecked-enabled state drawable
        ShapeDrawable uncheckedEnabledFrontCore = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
        uncheckedEnabledFrontCore.getPaint().setColor(attributes.getColor(2));
        InsetDrawable uncheckedEnabledFront = new InsetDrawable(uncheckedEnabledFrontCore, padding);

        ShapeDrawable uncheckedEnabledBack = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
        uncheckedEnabledBack.getPaint().setColor(Color.parseColor("#f2f2f2"));
        uncheckedEnabledBack.setIntrinsicWidth(space / 2 * 5);
        uncheckedEnabledBack.setIntrinsicHeight(space);
        uncheckedEnabledBack.setPadding(0, 0, space / 2 * 5, 0);

        Drawable[] d1 = { uncheckedEnabledBack, uncheckedEnabledFront };
        LayerDrawable uncheckedEnabled = new LayerDrawable(d1);

        // creating checked-enabled state drawable
        ShapeDrawable checkedEnabledFrontCore = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
        checkedEnabledFrontCore.getPaint().setColor(attributes.getColor(2));
        InsetDrawable checkedEnabledFront = new InsetDrawable(checkedEnabledFrontCore, padding);

        ShapeDrawable checkedEnabledBack = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
        checkedEnabledBack.getPaint().setColor(attributes.getColor(3));
        checkedEnabledBack.setPadding(space / 2 * 5, 0, 0, 0);

        Drawable[] d2 = { checkedEnabledBack, checkedEnabledFront };
        LayerDrawable checkedEnabled = new LayerDrawable(d2);

        // creating unchecked-disabled state drawable
        ShapeDrawable uncheckedDisabledFrontCore = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
        uncheckedDisabledFrontCore.getPaint().setColor(Color.parseColor("#d2d2d2"));
        InsetDrawable uncheckedDisabledFront = new InsetDrawable(uncheckedDisabledFrontCore, padding);

        ShapeDrawable uncheckedDisabledBack = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
        uncheckedDisabledBack.getPaint().setColor(Color.parseColor("#f2f2f2"));
        uncheckedDisabledBack.setPadding(0, 0, space / 2 * 5, 0);

        Drawable[] d3 = { uncheckedDisabledBack, uncheckedDisabledFront };
        LayerDrawable uncheckedDisabled = new LayerDrawable(d3);

        // creating checked-disabled state drawable
        ShapeDrawable checkedDisabledFrontCore = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
        checkedDisabledFrontCore.getPaint().setColor(attributes.getColor(3));
        InsetDrawable checkedDisabledFront = new InsetDrawable(checkedDisabledFrontCore, padding);

        ShapeDrawable checkedDisabledBack = new ShapeDrawable(new RoundRectShape(attributes.getOuterRadius(), null, null));
        checkedDisabledBack.getPaint().setColor(Color.parseColor("#f2f2f2"));
        checkedDisabledBack.setPadding(space / 2 * 5, 0, 0, 0);

        Drawable[] d4 = { checkedDisabledBack, checkedDisabledFront };
        LayerDrawable checkedDisabled = new LayerDrawable(d4);

        StateListDrawable states = new StateListDrawable();

        states.addState(new int[] { -android.R.attr.state_checked, android.R.attr.state_enabled }, new InsetDrawable(uncheckedEnabled, padding * 2));
        states.addState(new int[] { android.R.attr.state_checked, android.R.attr.state_enabled }, new InsetDrawable(checkedEnabled, padding * 2));
        states.addState(new int[] { -android.R.attr.state_checked, -android.R.attr.state_enabled }, new InsetDrawable(uncheckedDisabled, padding * 2));
        states.addState(new int[] { android.R.attr.state_checked, -android.R.attr.state_enabled }, new InsetDrawable(checkedDisabled, padding * 2));

        setBackgroundDrawable(states);

        setText("");
        setTextOff("");
        setTextOn("");

        setTextSize(0);
    }
 
Example 17
Source File: ShapeDrawActivity.java    From coursera-android with MIT License 4 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.main);

	int width = (int) getResources().getDimension(R.dimen.image_width);
	int height = (int) getResources().getDimension(R.dimen.image_height);
	int padding = (int) getResources().getDimension(R.dimen.padding);

	// Get container View
	RelativeLayout rl = findViewById(R.id.main_window);

	// Create Cyan Shape
	ShapeDrawable cyanShape = new ShapeDrawable(new OvalShape());
	cyanShape.getPaint().setColor(Color.CYAN);
	cyanShape.setIntrinsicHeight(height);
	cyanShape.setIntrinsicWidth(width);
	cyanShape.setAlpha(ALPHA);

	// Put Cyan Shape into an ImageView
	ImageView cyanView = new ImageView(getApplicationContext());
	cyanView.setImageDrawable(cyanShape);
	cyanView.setPadding(padding, padding, padding, padding);

	// Specify placement of ImageView within RelativeLayout
	RelativeLayout.LayoutParams cyanViewLayoutParams = new RelativeLayout.LayoutParams(
			height, width);
	cyanViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
	cyanViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
	cyanView.setLayoutParams(cyanViewLayoutParams);
	rl.addView(cyanView);

	// Create Magenta Shape
	ShapeDrawable magentaShape = new ShapeDrawable(new OvalShape());
	magentaShape.getPaint().setColor(Color.MAGENTA);
	magentaShape.setIntrinsicHeight(height);
	magentaShape.setIntrinsicWidth(width);
	magentaShape.setAlpha(ALPHA);

	// Put Magenta Shape into an ImageView
	ImageView magentaView = new ImageView(getApplicationContext());
	magentaView.setImageDrawable(magentaShape);
	magentaView.setPadding(padding, padding, padding, padding);

	// Specify placement of ImageView within RelativeLayout
	RelativeLayout.LayoutParams magentaViewLayoutParams = new RelativeLayout.LayoutParams(
			height, width);
	magentaViewLayoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
	magentaViewLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

	magentaView.setLayoutParams(magentaViewLayoutParams);

	rl.addView(magentaView);

}
 
Example 18
Source File: VerticalSeekBar.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 4 votes vote down vote up
private void grxSetUPAdditionalOptions(TypedArray a){

        mGrxZeroOffset = a.getInt(R.styleable.VerticalSeekBar_zeroOffset,0);
        mGrxDividerStep = a.getInt(R.styleable.VerticalSeekBar_dividerStep,0);
        mGrxHalfDividerLength = a.getDimension(R.styleable.VerticalSeekBar_dividerLength,0f)/2;
        mGrxHalfDividerThickness = a.getDimensionPixelSize(R.styleable.VerticalSeekBar_dividerThickness,0)/2;
        mGrxHalfProgressThickness = a.getDimensionPixelSize(R.styleable.VerticalSeekBar_progressThickness,0)/2;
        mGrxShowBackgroundTrack = a.getBoolean(R.styleable.VerticalSeekBar_showBackgroundTrack,true);
        mGrxZeroOffsetCircleRadius = a.getDimensionPixelSize(R.styleable.VerticalSeekBar_zeroOffsetCircleRadius,0);
        mGrxMin = a.getInt(R.styleable.VerticalSeekBar_min,0);

        mGrxNumSteps = getMax() - mGrxMin;
        mGrxProgressPaint = new Paint();
        mGrxProgressPaint.setStyle(Paint.Style.FILL);

        TypedValue typedValue = new TypedValue();
        TypedArray b = getContext().obtainStyledAttributes(typedValue.data, new int[] { android.R.attr.colorAccent });
        int color = b.getColor(0, 0);
        b.recycle();

        mGrxProgressPaint.setColor(color);

        Drawable currentprogressdrawable = getProgressDrawable();
        Drawable track = null;
        mGrxShowBackgroundTrack=false;//bbb
        if(currentprogressdrawable!= null && currentprogressdrawable instanceof LayerDrawable) {
            if (!mGrxShowBackgroundTrack){
                int indexbg = ((LayerDrawable) currentprogressdrawable).findIndexByLayerId(android.R.id.background);
                ((LayerDrawable) currentprogressdrawable).setDrawable(indexbg, new ColorDrawable(0));
            }

           int indexprogress = ((LayerDrawable) currentprogressdrawable).findIndexByLayerId(android.R.id.progress);
           ((LayerDrawable) currentprogressdrawable).setDrawable(indexprogress, new ColorDrawable(0));

        }

        mGrxDividerPaint = new Paint();
        mGrxDividerPaint.setStyle(Paint.Style.FILL_AND_STROKE);
        mGrxDividerPaint.setColor(color);
        mGrxDividerPaint.setStrokeWidth(2.0f);

        mTickMark = new ShapeDrawable(new OvalShape());
        mTickMark.setIntrinsicHeight(10);
        mTickMark.setIntrinsicWidth(10);
        mTickMark.getPaint().setColor(color);
        mTickMark.setBounds(new Rect(-2, -2, 2, 2));

        mTickMarkSoft = new ShapeDrawable(new OvalShape());
        mTickMarkSoft.setIntrinsicHeight(10);
        mTickMarkSoft.setIntrinsicWidth(10);
        mTickMarkSoft.getPaint().setColor(color&0x10ffffff);
        mTickMarkSoft.setBounds(new Rect(-4, -4, 4, 4));
    }
 
Example 19
Source File: ViewHolder0.java    From explorer with Apache License 2.0 3 votes vote down vote up
private ShapeDrawable getBackground(int color) {

        ShapeDrawable shapeDrawable = new ShapeDrawable(new OvalShape());

        int size = (int) context.getResources().getDimension(R.dimen.avatar_size);

        shapeDrawable.setIntrinsicWidth(size);

        shapeDrawable.setIntrinsicHeight(size);

        shapeDrawable.getPaint().setColor(color);

        return shapeDrawable;
    }
 
Example 20
Source File: AddTagAdapter.java    From talk-android with MIT License votes vote down vote up
public TagViewHolder(View itemView) {
            super(itemView);
            ShapeDrawable drawable = new ShapeDrawable(new OvalShape());
            final int size = DensityUtil.dip2px(itemView.getContext(), 8.0f);
            drawable.setIntrinsicHeight(size);
            drawable.setIntrinsicWidth(size);
            drawable.setBounds(0, 0, size, size);
            drawable.getPaint().setColor(itemView.getResources().getColor(R.color.colorPrimary));
            tagText = (TextView) itemView.findViewById(R.id.tag_text);
            tagText.setCompoundDrawables(drawable, null, null, null);
            tagSelectImage = (ImageView) itemView.findViewById(R.id.tag_check);
            final Drawable selectImage = ThemeUtil.getDrawableWithColor(itemView.getResources(), R.drawable.ic_save_blue, R.color.colorPrimary);
            tagSelectImage.setImageDrawable(selectImage);
        }