Example usage for android.view ViewGroup setDrawingCacheQuality

List of usage examples for android.view ViewGroup setDrawingCacheQuality

Introduction

In this page you can find the example usage for android.view ViewGroup setDrawingCacheQuality.

Prototype

@Deprecated
public void setDrawingCacheQuality(@DrawingCacheQuality int quality) 

Source Link

Document

Set the drawing cache quality of this view.

Usage

From source file:com.vuze.android.remote.activity.LoginActivity.java

@SuppressWarnings("deprecation")
private void setBackgroundGradient() {

    ViewGroup mainLayout = (ViewGroup) findViewById(R.id.main_loginlayout);
    assert mainLayout != null;
    int h = mainLayout.getHeight();
    int w = mainLayout.getWidth();
    View viewCenterOn = findViewById(R.id.login_frog_logo);
    assert viewCenterOn != null;

    RectShape shape = new RectShape();
    ShapeDrawable mDrawable = new ShapeDrawable(shape);
    int color1 = AndroidUtilsUI.getStyleColor(this, R.attr.login_grad_color_1);
    int color2 = AndroidUtilsUI.getStyleColor(this, R.attr.login_grad_color_2);

    RadialGradient shader;//w  ww  .  j a va 2s. co m
    if (w > h) {
        int left = viewCenterOn.getLeft() + (viewCenterOn.getWidth() / 2);
        int top = viewCenterOn.getTop() + (viewCenterOn.getHeight() / 2);
        int remaining = w - left;
        shader = new RadialGradient(left, top, remaining, new int[] { color1, color2 }, new float[] { 0, 1.0f },
                Shader.TileMode.CLAMP);
    } else {
        int top = viewCenterOn.getTop() + (viewCenterOn.getHeight() / 2);
        shader = new RadialGradient(w / 2, top, w * 2 / 3, color1, color2, Shader.TileMode.CLAMP);
    }
    mDrawable.setBounds(0, 0, w, h);
    mDrawable.getPaint().setShader(shader);
    mDrawable.getPaint().setDither(true);
    mDrawable.getPaint().setAntiAlias(true);
    mDrawable.setDither(true);

    mainLayout.setDrawingCacheEnabled(true);
    mainLayout.setDrawingCacheQuality(View.DRAWING_CACHE_QUALITY_HIGH);
    mainLayout.setAnimationCacheEnabled(false);

    mainLayout.setBackgroundDrawable(mDrawable);
}