@@ -11932,13 +11932,13 @@ public boolean isDuplicateParentStateEnabled() {
1193211932 * {@link #setAlpha(float)}, the alpha value of the layer's paint is replaced by
1193311933 * this view's alpha value. Calling {@link #setAlpha(float)} is therefore
1193411934 * equivalent to setting a hardware layer on this view and providing a paint with
11935- * the desired alpha value.<p>
11935+ * the desired alpha value.</ p>
1193611936 *
1193711937 * <p>Refer to the documentation of {@link #LAYER_TYPE_NONE disabled},
1193811938 * {@link #LAYER_TYPE_SOFTWARE software} and {@link #LAYER_TYPE_HARDWARE hardware}
1193911939 * for more information on when and how to use layers.</p>
1194011940 *
11941- * @param layerType The ype of layer to use with this view, must be one of
11941+ * @param layerType The type of layer to use with this view, must be one of
1194211942 * {@link #LAYER_TYPE_NONE}, {@link #LAYER_TYPE_SOFTWARE} or
1194311943 * {@link #LAYER_TYPE_HARDWARE}
1194411944 * @param paint The paint used to compose the layer. This argument is optional
@@ -11989,6 +11989,50 @@ public void setLayerType(int layerType, Paint paint) {
1198911989 invalidate(true);
1199011990 }
1199111991
11992+ /**
11993+ * Updates the {@link Paint} object used with the current layer (used only if the current
11994+ * layer type is not set to {@link #LAYER_TYPE_NONE}). Changed properties of the Paint
11995+ * provided to {@link #setLayerType(int, android.graphics.Paint)} will be used the next time
11996+ * the View is redrawn, but {@link #setLayerPaint(android.graphics.Paint)} must be called to
11997+ * ensure that the view gets redrawn immediately.
11998+ *
11999+ * <p>A layer is associated with an optional {@link android.graphics.Paint}
12000+ * instance that controls how the layer is composed on screen. The following
12001+ * properties of the paint are taken into account when composing the layer:</p>
12002+ * <ul>
12003+ * <li>{@link android.graphics.Paint#getAlpha() Translucency (alpha)}</li>
12004+ * <li>{@link android.graphics.Paint#getXfermode() Blending mode}</li>
12005+ * <li>{@link android.graphics.Paint#getColorFilter() Color filter}</li>
12006+ * </ul>
12007+ *
12008+ * <p>If this view has an alpha value set to < 1.0 by calling
12009+ * {@link #setAlpha(float)}, the alpha value of the layer's paint is replaced by
12010+ * this view's alpha value. Calling {@link #setAlpha(float)} is therefore
12011+ * equivalent to setting a hardware layer on this view and providing a paint with
12012+ * the desired alpha value.</p>
12013+ *
12014+ * @param paint The paint used to compose the layer. This argument is optional
12015+ * and can be null. It is ignored when the layer type is
12016+ * {@link #LAYER_TYPE_NONE}
12017+ *
12018+ * @see #setLayerType(int, android.graphics.Paint)
12019+ */
12020+ public void setLayerPaint(Paint paint) {
12021+ int layerType = getLayerType();
12022+ if (layerType != LAYER_TYPE_NONE) {
12023+ mLayerPaint = paint == null ? new Paint() : paint;
12024+ if (layerType == LAYER_TYPE_HARDWARE) {
12025+ HardwareLayer layer = getHardwareLayer();
12026+ if (layer != null) {
12027+ layer.setLayerPaint(paint);
12028+ }
12029+ invalidateViewProperty(false, false);
12030+ } else {
12031+ invalidate();
12032+ }
12033+ }
12034+ }
12035+
1199212036 /**
1199312037 * Indicates whether this view has a static layer. A view with layer type
1199412038 * {@link #LAYER_TYPE_NONE} is a static layer. Other types of layers are
@@ -12101,6 +12145,7 @@ HardwareLayer getHardwareLayer() {
1210112145 if (!mHardwareLayer.isValid()) {
1210212146 return null;
1210312147 }
12148+ mHardwareLayer.setLayerPaint(mLayerPaint);
1210412149
1210512150 mHardwareLayer.redraw(getHardwareLayerDisplayList(mHardwareLayer), mLocalDirtyRect);
1210612151 mLocalDirtyRect.setEmpty();
0 commit comments