Example usage for android.graphics.drawable GradientDrawable setGradientRadius

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

Introduction

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

Prototype

public void setGradientRadius(float gradientRadius) 

Source Link

Document

Sets the radius of the gradient.

Usage

From source file:com.linroid.pushapp.ui.setting.AboutActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (toolbar != null) {
        setSupportActionBar(toolbar);//  w  w w  .j  a v  a2  s.  c  o m
        ViewCompat.setElevation(toolbar, 0);
    }
    initVersionName();
    GradientDrawable drawable = (GradientDrawable) headerContainer.getBackground();
    drawable.setGradientRadius(getResources().getDimensionPixelOffset(R.dimen.about_header_bg_radius));
    headerContainer.setBackgroundDrawable(drawable);
}

From source file:com.bilibili.magicasakura.utils.GradientDrawableUtils.java

void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType)
        throws XmlPullParserException {
    TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs,
            new int[] { android.R.attr.gradientRadius });
    TypedValue value = a.peekValue(0);//from w  w w .  j ava 2  s  .  c o m
    if (value != null) {
        boolean radiusRel = value.type == TypedValue.TYPE_FRACTION;
        drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat());
    } else if (gradientType == GradientDrawable.RADIAL_GRADIENT) {
        throw new XmlPullParserException(
                "<gradient> tag requires 'gradientRadius' " + "attribute with radial type");
    }
    a.recycle();
}

From source file:com.bilibili.magicasakura.utils.GradientDrawableInflateImpl.java

void setGradientRadius(Context context, AttributeSet attrs, GradientDrawable drawable, int gradientType)
        throws XmlPullParserException {
    TypedArray a = DrawableUtils.obtainAttributes(context.getResources(), context.getTheme(), attrs,
            new int[] { android.R.attr.gradientRadius });
    TypedValue value = a.peekValue(0);/*from ww  w . ja  v a  2 s  .c  o m*/
    if (value != null) {
        boolean radiusRel = value.type == TypedValue.TYPE_FRACTION;
        drawable.setGradientRadius(radiusRel ? value.getFraction(1.0f, 1.0f) : value.getFloat());
    } else if (gradientType == GradientDrawable.RADIAL_GRADIENT) {
        throw new XmlPullParserException(
                "<gradient> tag requires 'gradientRadius' " + "attribute with radial type");
    }
    a.recycle();
}