Example usage for android.graphics.drawable GradientDrawable setSize

List of usage examples for android.graphics.drawable GradientDrawable setSize

Introduction

In this page you can find the example usage for android.graphics.drawable GradientDrawable setSize.

Prototype

public void setSize(int width, int height) 

Source Link

Document

Sets the size of the shape drawn by this drawable.

Note: changing this property will affect all instances of a drawable loaded from a resource.

Usage

From source file:com.mixiaoxiao.support.widget.SmoothSwitch.java

private GradientDrawable makeTrackDrawable(int color, int thumbWidth, int thumbHeight, float radius,
        int padding) {
    GradientDrawable trackDrawable = new GradientDrawable();
    if (padding > 0) {
        trackDrawable.setStroke(padding, Color.TRANSPARENT);
    }// ww  w . j  a  v a  2  s. c  o  m
    trackDrawable.setCornerRadius(radius);
    trackDrawable.setSize((int) (thumbWidth * Default.DEFAULT_MEASURE_FACTOR), thumbHeight);
    trackDrawable.setColor(getTrackColor(color));
    return trackDrawable;
}

From source file:com.mixiaoxiao.support.widget.SmoothSwitch.java

private GradientDrawable makeThumbDrawable(int color, int thumbWidth, int thumbHeight, float radius,
        int padding) {
    GradientDrawable thumbDrawable = new GradientDrawable();
    if (padding > 0) {
        thumbDrawable.setStroke(padding, Color.TRANSPARENT);//make a transparent stroke ,just like padding
    }//from   w  ww.  ja  v a 2  s.  co m
    thumbDrawable.setCornerRadius(radius);
    thumbDrawable.setSize(thumbWidth, thumbHeight);
    thumbDrawable.setColor(color);
    return thumbDrawable;
}