本文整理汇总了Java中android.view.ViewGroup.setDrawingCacheEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ViewGroup.setDrawingCacheEnabled方法的具体用法?Java ViewGroup.setDrawingCacheEnabled怎么用?Java ViewGroup.setDrawingCacheEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.ViewGroup
的用法示例。
在下文中一共展示了ViewGroup.setDrawingCacheEnabled方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: showBlur
import android.view.ViewGroup; //导入方法依赖的package包/类
/**
* 模糊处理
* @return
*/
private boolean showBlur() {
if (!blurBackground) {
return false;
}
setVisibility(INVISIBLE);
final ViewGroup root = (ViewGroup) getRootView();
root.setDrawingCacheEnabled(true);
Bitmap bitmap = root.getDrawingCache();
checkBlurRadius();
blur.setParams(new Blur.Callback() {
@Override
public void onBlurred(Bitmap blurredBitmap) {
blurImageView.setImageBitmap(blurredBitmap);
root.setDrawingCacheEnabled(false);
root.addView(blurImageView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
blurAnimator = ObjectAnimator.ofFloat(blurImageView, "alpha", 0.0f, 1.0f).setDuration(expandAnimDuration);
if (blurListener != null) {
blurAnimator.removeListener(blurListener);
}
blurAnimator.start();
root.addView(maskView);
maskAttached = true;
maskView.reset();
maskView.initButtonRect();
maskView.onClickMainButton();
}
}, getContext(), bitmap, blurRadius);
blur.execute();
return true;
}
示例2: onInterceptTouchEvent
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if ((mDragListener != null || mDropListener != null)
&& ev.getAction() == MotionEvent.ACTION_DOWN) {
int x = (int) ev.getX();
int y = (int) ev.getY();
int itemnum = pointToPosition(x, y);
if (itemnum != AdapterView.INVALID_POSITION) {
ViewGroup item = (ViewGroup) getChildAt(itemnum - getFirstVisiblePosition());
Log.d("DnD view", "Start dragging at " + (itemnum - getFirstVisiblePosition()) + " for "+ itemnum + " # "+ getFirstVisiblePosition());
mDragPoint = y - item.getTop();
mCoordOffset = ((int) ev.getRawY()) - y;
View dragger = item.findViewById(grabberId);
if(dragger == null || dragger.getVisibility() == View.GONE) {
return super.onInterceptTouchEvent(ev);
}
Rect r = mTempRect;
r.left=dragger.getLeft();
r.right=dragger.getRight();
r.top=dragger.getTop();
r.bottom=dragger.getBottom();
if ((r.left<x) && (x<r.right)) {
item.setDrawingCacheEnabled(true);
// Create a copy of the drawing cache so that it does
// not get recycled
// by the framework when the list tries to clean up
// memory
Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
startDragging(bitmap, y);
mDragPos = itemnum;
mFirstDragPos = mDragPos;
mHeight = getHeight();
int touchSlop = mTouchSlop;
mUpperBound = Math.min(y - touchSlop, mHeight / 3);
mLowerBound = Math.max(y + touchSlop, mHeight * 2 / 3);
item.setDrawingCacheEnabled(false);
return false;
}
mDragView = null;
}
}
return super.onInterceptTouchEvent(ev);
}
示例3: Dragger
import android.view.ViewGroup; //导入方法依赖的package包/类
public Dragger(Context context, Setting setting, ViewGroup item, MotionEvent ev) {
mSetting = setting;
int y = (int) ev.getY();
mDragPointOffset = y - item.getTop();
mCoordOffset = ((int)ev.getRawY()) - y;
mRowHeight = item.getHeight();
// enable cache
// clear cache, otherwise we are going to have problems in donut ;)
item.setDrawingCacheEnabled(false);
item.setDrawingCacheEnabled(true);
// create bitmap
Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
mBitmap = bitmap;
// create window
mWindowParams = new WindowManager.LayoutParams();
WindowManager.LayoutParams params = mWindowParams;
params.gravity = Gravity.TOP;
params.alpha = 0.65f;
params.x = 0;
params.y = y - mDragPointOffset + mCoordOffset;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.width = WindowManager.LayoutParams.WRAP_CONTENT;
params.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
| WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE
| WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
| WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN;
params.format = PixelFormat.TRANSLUCENT;
params.windowAnimations = 0;
ImageView imageView = new ImageView(context);
int backGroundColor = context.getResources().getColor(android.R.color.black);
imageView.setBackgroundColor(backGroundColor);
imageView.setImageBitmap(bitmap);
// add view
mWindowManager = (WindowManager) context.getSystemService("window");
mWindowManager.addView(imageView, params);
mImageView = imageView;
}
示例4: onInterceptTouchEvent
import android.view.ViewGroup; //导入方法依赖的package包/类
@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
if (mDragListener != null || mDropListener != null) {
switch (ev.getAction()) {
case MotionEvent.ACTION_DOWN:
int x = (int) ev.getX();
int y = (int) ev.getY();
int itemnum = pointToPosition(x, y);
if (itemnum == AdapterView.INVALID_POSITION) {
break;
}
ViewGroup item = (ViewGroup) getChildAt(itemnum - getFirstVisiblePosition());
mDragPoint = y - item.getTop();
mCoordOffset = ((int) ev.getRawY()) - y;
View dragger = item.findViewById(R.id.grabber);
Rect r = mTempRect;
dragger.getDrawingRect(r);
if (shouldStartDragging(x, r.width())) {
// Fix x position while dragging
int[] itemPos = new int[2];
item.getLocationOnScreen(itemPos);
item.setDrawingCacheEnabled(true);
// Create a copy of the drawing cache so that it does
// not get recycled
// by the framework when the list tries to clean up
// memory
Bitmap bitmap = Bitmap.createBitmap(item.getDrawingCache());
startDragging(bitmap, itemPos[0], y);
mDragPos = itemnum;
mFirstDragPos = mDragPos;
mHeight = getHeight();
int touchSlop = mTouchSlop;
mUpperBound = Math.min(y - touchSlop, mHeight / 3);
mLowerBound = Math.max(y + touchSlop, mHeight * 2 / 3);
return false;
}
stopDragging();
break;
}
}
return super.onInterceptTouchEvent(ev);
}