下面列出了android.view.View#LAYER_TYPE_SOFTWARE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* The shape of the cropping area - rectangle/circular.
*/
public void setCropShape(CropImageView.CropShape cropShape) {
if (mCropShape != cropShape) {
mCropShape = cropShape;
if (Build.VERSION.SDK_INT <= 17) {
if (mCropShape == CropImageView.CropShape.OVAL) {
mOriginalLayerType = getLayerType();
if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
// TURN off hardware acceleration
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
} else {
mOriginalLayerType = null;
}
} else if (mOriginalLayerType != null) {
// return hardware acceleration back
setLayerType(mOriginalLayerType, null);
mOriginalLayerType = null;
}
}
invalidate();
}
}
/** The shape of the cropping area - rectangle/circular. */
public void setCropShape(CropImageView.CropShape cropShape) {
if (mCropShape != cropShape) {
mCropShape = cropShape;
if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 17) {
if (mCropShape == CropImageView.CropShape.OVAL) {
mOriginalLayerType = getLayerType();
if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
// TURN off hardware acceleration
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
} else {
mOriginalLayerType = null;
}
} else if (mOriginalLayerType != null) {
// return hardware acceleration back
setLayerType(mOriginalLayerType, null);
mOriginalLayerType = null;
}
}
invalidate();
}
}
/**
* The shape of the cropping area - rectangle/circular.
*/
public void setCropShape(CropImageView.CropShape cropShape) {
if (mCropShape != cropShape) {
mCropShape = cropShape;
if (Build.VERSION.SDK_INT >= 11 && Build.VERSION.SDK_INT <= 17) {
if (mCropShape == CropImageView.CropShape.OVAL) {
mOriginalLayerType = getLayerType();
if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
// TURN off hardware acceleration
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
} else {
mOriginalLayerType = null;
}
} else if (mOriginalLayerType != null) {
// return hardware acceleration back
setLayerType(mOriginalLayerType, null);
mOriginalLayerType = null;
}
}
invalidate();
}
}
private void configLayerType(ViewHolder holder) {
boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
if (!disableHardAccelerated) {
return;
}
int currentWidgetLayerType = holder.username.getLayerType();
if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
holder.username.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (holder.weiboTextContent != null) {
holder.weiboTextContent.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
if (holder.time != null) {
holder.time.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
}
void updateFromViewRotation() {
if (Build.VERSION.SDK_INT == 19) {
// KitKat seems to have an issue with views which are rotated with angles which are
// not divisible by 90. Worked around by moving to software rendering in these cases.
if ((rotation % 90) != 0) {
if (view.getLayerType() != View.LAYER_TYPE_SOFTWARE) {
view.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
} else {
if (view.getLayerType() != View.LAYER_TYPE_NONE) {
view.setLayerType(View.LAYER_TYPE_NONE, null);
}
}
}
// Offset any View rotation
if (shapeDrawable != null) {
shapeDrawable.setShadowCompatRotation((int) rotation);
}
}
/** The shape of the cropping area - rectangle/circular. */
public void setCropShape(CropImageView.CropShape cropShape) {
if (mCropShape != cropShape) {
mCropShape = cropShape;
if (Build.VERSION.SDK_INT <= 17) {
if (mCropShape == CropImageView.CropShape.OVAL) {
mOriginalLayerType = getLayerType();
if (mOriginalLayerType != View.LAYER_TYPE_SOFTWARE) {
// TURN off hardware acceleration
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
} else {
mOriginalLayerType = null;
}
} else if (mOriginalLayerType != null) {
// return hardware acceleration back
setLayerType(mOriginalLayerType, null);
mOriginalLayerType = null;
}
}
invalidate();
}
}
private void configLayerType(ViewHolder holder) {
boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
if (!disableHardAccelerated) {
return;
}
int currentWidgetLayerType = holder.username.getLayerType();
if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
holder.username.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (holder.content != null) {
holder.content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
}
private void configLayerType(ViewHolder holder) {
boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
if (!disableHardAccelerated) {
return;
}
int currentWidgetLayerType = holder.username.getLayerType();
if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
holder.username.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (holder.content != null) {
holder.content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
}
/**
* In this, you can set TouchEffectDrawable,
* to init TouchEffectDrawable.
* <p>
* If you not need touch effect,
* you should set NULL.
* <p>
* But, if need it,
* you should call {@link TouchEffectDrawable#setEffect(Effect)}
*
* @param touchDrawable TouchEffectDrawable
*/
public void setTouchDrawable(TouchEffectDrawable touchDrawable) {
if (mTouchDrawable != touchDrawable) {
if (mTouchDrawable != null) {
mTouchDrawable.setCallback(null);
}
if (touchDrawable != null) {
touchDrawable.setCallback(this);
// We must set layer type is View.LAYER_TYPE_SOFTWARE,
// to support Canvas.clipPath()
// on Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
if (getLayerType() != View.LAYER_TYPE_SOFTWARE)
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
mTouchDrawable = touchDrawable;
}
}
/**
* In this, you can set TouchEffectDrawable,
* to init TouchEffectDrawable.
* <p>
* If you not need touch effect,
* you should set NULL.
* <p>
* But, if need it,
* you should call {@link TouchEffectDrawable#setEffect(Effect)}
*
* @param touchDrawable TouchEffectDrawable
*/
public void setTouchDrawable(TouchEffectDrawable touchDrawable) {
if (mTouchDrawable != touchDrawable) {
if (mTouchDrawable != null) {
mTouchDrawable.setCallback(null);
}
if (touchDrawable != null) {
touchDrawable.setCallback(this);
// We must set layer type is View.LAYER_TYPE_SOFTWARE,
// to support Canvas.clipPath()
// on Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB
if (getLayerType() != View.LAYER_TYPE_SOFTWARE)
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
mTouchDrawable = touchDrawable;
}
}
@Override
public void setLayerType(int layerType, Paint paint) {
// In this, to support Canvas.clipPath(),
// must set layerType is View.LAYER_TYPE_SOFTWARE
layerType = View.LAYER_TYPE_SOFTWARE;
super.setLayerType(layerType, paint);
}
public void setClipOutEnable(boolean clip) {
if (mClipOutEnable != clip) {
if (mLayerType != View.LAYER_TYPE_SOFTWARE) {
setLayerType(clip ? View.LAYER_TYPE_SOFTWARE : mLayerType, null);
}
mClipOutEnable = clip;
invalidate();
}
}
private void configLayerType(ViewHolder holder) {
boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
if (!disableHardAccelerated) {
return;
}
int currentWidgetLayerType = holder.username.getLayerType();
if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
holder.username.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (holder.weiboTextContent != null) {
holder.weiboTextContent.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
if (holder.repost_content != null) {
holder.repost_content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
if (holder.time != null) {
holder.time.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
if (holder.repost_count != null) {
holder.repost_count.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
if (holder.comment_count != null) {
holder.comment_count.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
}
RevealFinishedIceCreamSandwich(CircularRevealAnimator target) {
super(target);
mLayerType = ((View) target).getLayerType();
mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
RevealFinishedIceCreamSandwich(RevealAnimator target) {
super(target);
mLayerType = ((View) target).getLayerType();
mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
RevealFinishedIceCreamSandwich(RevealAnimator target) {
super(target);
mLayerType = ((View) target).getLayerType();
mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
RevealFinishedIceCreamSandwich(RevealAnimator target) {
super(target);
mLayerType = ((View) target).getLayerType();
mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
RevealFinishedIceCreamSandwich(RevealAnimator target) {
super(target);
mLayerType = ((View) target).getLayerType();
mFeaturedLayerType = View.LAYER_TYPE_SOFTWARE;
}
private void configLayerType(ViewHolder holder) {
boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
if (!disableHardAccelerated)
return;
int currentWidgetLayerType = holder.content.getLayerType();
if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
holder.content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (holder.time != null)
holder.time.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}
private void configLayerType(ViewHolder holder) {
boolean disableHardAccelerated = SettingUtils.disableHardwareAccelerated();
if (!disableHardAccelerated)
return;
int currentWidgetLayerType = holder.content.getLayerType();
if (View.LAYER_TYPE_SOFTWARE != currentWidgetLayerType) {
holder.content.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (holder.time != null)
holder.time.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}