Android examples for User Interface:View Layer
set View Layer Paint Type
//package com.java2s; import java.lang.reflect.Method; import android.graphics.Paint; import android.view.View; public class Main { private static final String METHOD_SET_LAYER_TYPE = "setLayerType"; private static final String METHOD_GET_LAYER_TYPE = "getLayerType"; public static void setLayerType(View view, int layerType, Paint paint) { if (view == null) { return; }/*from w w w. j a v a2s. co m*/ Method methodSet; Method methodGet; try { methodGet = View.class.getDeclaredMethod(METHOD_GET_LAYER_TYPE); if (methodGet == null) { return; } int type = (Integer) methodGet.invoke(view); if (type == layerType) { return; } methodSet = View.class.getDeclaredMethod(METHOD_SET_LAYER_TYPE, int.class, Paint.class); if (methodSet != null) { methodSet.invoke(view, layerType, paint); } } catch (Exception e) { } } }