Example usage for android.view View LAYER_TYPE_SOFTWARE

List of usage examples for android.view View LAYER_TYPE_SOFTWARE

Introduction

In this page you can find the example usage for android.view View LAYER_TYPE_SOFTWARE.

Prototype

int LAYER_TYPE_SOFTWARE

To view the source code for android.view View LAYER_TYPE_SOFTWARE.

Click Source Link

Document

Indicates that the view has a software layer.

Usage

From source file:Main.java

public static void compatDisableViewHardware(View view) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        try {/*from   ww w.ja v a 2  s  .c om*/
            view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        } catch (NoSuchMethodError e) {
        }
    }
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void setLayerTypeSoftwareToView(View view) {
    if (Build.VERSION.SDK_INT >= 11) {
        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }//  w w  w . j a v  a  2 s . c  o  m
}

From source file:Main.java

@SuppressLint("NewApi")
public static void disableHardwareAcceleration(View v) {
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB)
        v.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

From source file:Main.java

/**
 * This method setting layer type to sowftware.
 *
 * @param view view which would be set.//from  ww  w  .j  a  v  a2 s.c  o  m
 */
public static void setLayerToSW(View view) {
    if (!view.isInEditMode() && Build.VERSION.SDK_INT >= 11) {
        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
}

From source file:Main.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static void disableHardwareAcceleration(View view) {
    // HA was introduced in Honeycomb.
    if (isHoneycomb())
        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}

From source file:Main.java

/**
 * Method that removes the support for HardwareAcceleration from a {@link View}.<br/>
 * <br/>/*from  w  w w  .j  a  va  2s. c om*/
 * Check AOSP notice:<br/>
 * <pre>
 * 'ComposeShader can only contain shaders of different types (a BitmapShader and a
 * LinearGradient for instance, but not two instances of BitmapShader)'. But, 'If your
 * application is affected by any of these missing features or limitations, you can turn
 * off hardware acceleration for just the affected portion of your application by calling
 * setLayerType(View.LAYER_TYPE_SOFTWARE, null).'</pre>
 *
 * @param v The view
 */
public static void removeHardwareAccelerationSupport(View v) {
    if (v.getLayerType() != View.LAYER_TYPE_SOFTWARE) {
        v.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }
}

From source file:com.rk.lib.view.SVGView.java

/**
 * Loads the initial resource for the View.
 * //from  w  w w .  j  a  v  a2 s . co m
 * @param context
 *            - The Context associated with the view.
 * @param attrs
 *            - The AttributeSet associated with the view.
 * @param defStyle
 *            - The style associated with the view.
 */
public void init(Context context, AttributeSet attrs, int defStyle) {
    if (!isInEditMode()) {
        setLayerType(View.LAYER_TYPE_SOFTWARE, null);
        mContext = context;
        final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
        final int cacheSize = maxMemory / 8;
        memoryCache = new LruCache<Integer, Drawable>(cacheSize);
        TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.SVGView,
                defStyle, 0);
        resourceId = typedArray.getResourceId(R.styleable.SVGView_source, -1);
        isSvgResource = typedArray.getBoolean(R.styleable.SVGView_isSvg, false);
        if (resourceId != -1) {
            if (isSvgResource) {
                setCacheImageDrawable(resourceId, true);
            } else {
                setCacheImageDrawable(resourceId, false);
            }
        }
    }
}

From source file:com.app.chatbot.fragment.BaseFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(getFragmentLayout(), container, false);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
        view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    }/*from   www  . ja  v  a  2s. com*/
    injectViews(view);
    return view;
}

From source file:devlight.io.library.CutIntoLayout.java

public CutIntoLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    setWillNotDraw(false);/*  w  w  w.j  a va  2s.c  o  m*/
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, null);

    final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.CutIntoLayout);
    try {
        setMask(typedArray.getDrawable(R.styleable.CutIntoLayout_cil_mask));
    } finally {
        typedArray.recycle();
    }
}

From source file:com.tzapps.common.ui.view.PagerContainer.java

private void init() {
    // Disable clipping of children so non-selected pages are visible
    setClipChildren(false);/*from  w  w w  . j ava2s .c o  m*/

    // Child clipping doesn't work with hardware acceleration in Android 3.x/4.x
    // You need to set this value here if using hardware acceleration in an
    // application targeted at these releases.
    setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}