下面列出了android.view.View#isHardwareAccelerated ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private void prepareContent() {
if (mAnimating) {
return;
}
// Something changed in the content, we need to honor the layout request
// before creating the cached bitmap
final View content = mContent;
if (content.isLayoutRequested()) {
final int childHeight = mHandleHeight;
int height = getBottom() - getTop() - childHeight - mTopOffset;
content.measure(MeasureSpec.makeMeasureSpec(getRight() - getLeft(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
content.layout(0, mTopOffset + childHeight, content.getMeasuredWidth(), mTopOffset + childHeight + content.getMeasuredHeight());
}
// Try only once… we should really loop but it's not a big deal
// if the draw was cancelled, it will only be temporary anyway
content.getViewTreeObserver().dispatchOnPreDraw();
if (!content.isHardwareAccelerated())
content.buildDrawingCache();
content.setVisibility(View.GONE);
}
private void prepareContent() {
if (mAnimating) {
return;
}
// Something changed in the content, we need to honor the layout request
// before creating the cached bitmap
final View content = mContent;
if (content.isLayoutRequested()) {
if (mVertical) {
final int childHeight = mHandleHeight;
int height = mBottom - mTop - childHeight - mTopOffset;
content.measure(MeasureSpec.makeMeasureSpec(mRight - mLeft, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
content.layout(0, mTopOffset + childHeight, content.getMeasuredWidth(),
mTopOffset + childHeight + content.getMeasuredHeight());
} else {
final int childWidth = mHandle.getWidth();
int width = mRight - mLeft - childWidth - mTopOffset;
content.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(mBottom - mTop, MeasureSpec.EXACTLY));
content.layout(childWidth + mTopOffset, 0,
mTopOffset + childWidth + content.getMeasuredWidth(),
content.getMeasuredHeight());
}
}
// Try only once... we should really loop but it's not a big deal
// if the draw was cancelled, it will only be temporary anyway
content.getViewTreeObserver().dispatchOnPreDraw();
if (!content.isHardwareAccelerated()) content.buildDrawingCache();
content.setVisibility(View.GONE);
}
public static boolean isHardwareAccelerated(final View v) {
if (Build.VERSION.SDK_INT >= 11) {
try {
return v.isHardwareAccelerated();
} catch (Exception e) {
}
}
return false;
}
@Override
protected void setChildrenDrawingCacheEnabled(boolean enabled) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View view = getChildAt(i);
view.setDrawingCacheEnabled(enabled);
// Update the drawing caches
if (!view.isHardwareAccelerated() && enabled) {
view.buildDrawingCache(true);
}
}
}
@SuppressLint("NewApi")
public static void invalidateLayerTypeView(View[] views) {
for (View view : views) {
if (ViewUtil.viewVisibilityInParents(view) && view.isHardwareAccelerated()) {
checkAndInvalidate(view);
if (view instanceof ViewGroup) {
invalidateViewGroup((ViewGroup) view);
}
}
}
}
@Override
protected void setChildrenDrawingCacheEnabled(boolean enabled) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View view = getChildAt(i);
view.setDrawingCacheEnabled(enabled);
// Update the drawing caches
if (!view.isHardwareAccelerated()) {
view.buildDrawingCache(true);
}
}
}
@Override
protected void setChildrenDrawingCacheEnabled(boolean enabled) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View view = getChildAt(i);
view.setDrawingCacheEnabled(enabled);
// Update the drawing caches
if (!view.isHardwareAccelerated() && enabled) {
view.buildDrawingCache(true);
}
}
}
@Override
protected void setChildrenDrawingCacheEnabled(boolean enabled) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View view = getChildAt(i);
view.setDrawingCacheEnabled(enabled);
// Update the drawing caches
if (!view.isHardwareAccelerated()) {
view.buildDrawingCache(true);
}
}
}
@Override
protected void setChildrenDrawingCacheEnabled(boolean enabled) {
final int count = getChildCount();
for (int i = 0; i < count; i++) {
final View view = getChildAt(i);
view.setDrawingCacheEnabled(enabled);
// Update the drawing caches
if (!view.isHardwareAccelerated() && enabled) {
view.buildDrawingCache(true);
}
}
}
private void prepareContent() {
if (mAnimating) {
return;
}
// Something changed in the content, we need to honor the layout request
// before creating the cached bitmap
final View content = mContent;
if (content.isLayoutRequested()) {
if (mVertical) {
final int childHeight = mHandleHeight;
int height = getBottom() - getTop() - childHeight - mTopOffset;
content.measure(MeasureSpec.makeMeasureSpec(getRight() - getLeft(), MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
content.layout(0, mTopOffset + childHeight, content.getMeasuredWidth(),
mTopOffset + childHeight + content.getMeasuredHeight());
} else {
final int childWidth = mHandle.getWidth();
int width = getRight() - getLeft() - childWidth - mTopOffset;
content.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY),
MeasureSpec.makeMeasureSpec(getBottom() - getTop() , MeasureSpec.EXACTLY));
content.layout(childWidth + mTopOffset, 0,
mTopOffset + childWidth + content.getMeasuredWidth(),
content.getMeasuredHeight());
}
}
// Try only once... we should really loop but it's not a big deal
// if the draw was cancelled, it will only be temporary anyway
content.getViewTreeObserver().dispatchOnPreDraw();
if (!content.isHardwareAccelerated()) content.buildDrawingCache();
content.setVisibility(View.GONE);
}
public static boolean isHardwareAccelerated(View view) {
return view.isHardwareAccelerated();
}
public static boolean isHardwareAccelerated(View view) {
return view.isHardwareAccelerated();
}
public static boolean isHardwareAccelerated(View view) {
return view.isHardwareAccelerated();
}
public static boolean isHardwareAccelerated(View view) {
return view.isHardwareAccelerated();
}
public static boolean isHardwareAccelerated(View view) {
return view.isHardwareAccelerated();
}
public static boolean isHardwareAccelerated(View view) {
return view.isHardwareAccelerated();
}
public static boolean isHardwareAccelerated(View view) {
return view.isHardwareAccelerated();
}
public static boolean isHardwareAccelerated(View view) {
return view.isHardwareAccelerated();
}
public static boolean isHardwareAccelerated(View view) {
return view.isHardwareAccelerated();
}
@TargetApi(11)
private void checkHardwareAccelerated(View view)
{
if (!view.isHardwareAccelerated()) view.buildDrawingCache();
}