List of usage examples for android.view View LAYER_TYPE_HARDWARE
int LAYER_TYPE_HARDWARE
To view the source code for android.view View LAYER_TYPE_HARDWARE.
Click Source Link
Indicates that the view has a hardware layer.
From source file:nl.sogeti.android.gpstracker.viewer.LoggerMap.java
private void setupHardwareAcceleration() { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { return;/*from ww w .j a va 2 s . co m*/ } if (isHardwareAccelerated()) { mMapView.setLayerType(View.LAYER_TYPE_HARDWARE, null); } else { mMapView.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } }
From source file:com.android.printspooler.widget.PrintContentView.java
private void onDragProgress(float progress) { if (Float.compare(mDragProgress, progress) == 0) { return;/*w w w . j ava 2s.co m*/ } if ((mDragProgress == 0 && progress > 0) || (mDragProgress == 1.0f && progress < 1.0f)) { mSummaryContent.setLayerType(View.LAYER_TYPE_HARDWARE, null); mDraggableContent.setLayerType(View.LAYER_TYPE_HARDWARE, null); mMoreOptionsButton.setLayerType(View.LAYER_TYPE_HARDWARE, null); ensureImeClosedAndInputFocusCleared(); } if ((mDragProgress > 0 && progress == 0) || (mDragProgress < 1.0f && progress == 1.0f)) { mSummaryContent.setLayerType(View.LAYER_TYPE_NONE, null); mDraggableContent.setLayerType(View.LAYER_TYPE_NONE, null); mMoreOptionsButton.setLayerType(View.LAYER_TYPE_NONE, null); mMoreOptionsButton.setLayerType(View.LAYER_TYPE_NONE, null); } mDragProgress = progress; mSummaryContent.setAlpha(progress); final float inverseAlpha = 1.0f - progress; mOptionsContainer.setAlpha(inverseAlpha); mMoreOptionsButton.setAlpha(inverseAlpha); mEmbeddedContentScrim.setBackgroundColor(computeScrimColor()); if (progress == 0) { if (mOptionsStateChangeListener != null) { mOptionsStateChangeListener.onOptionsOpened(); } mExpandCollapseHandle.setContentDescription(mContext.getString(R.string.collapse_handle)); announceForAccessibility(mContext.getString(R.string.print_options_expanded)); mSummaryContent.setVisibility(View.GONE); mEmbeddedContentScrim.setOnClickListener(this); mExpandCollapseIcon.setBackgroundResource(R.drawable.ic_expand_less); } else { mSummaryContent.setVisibility(View.VISIBLE); } if (progress == 1.0f) { if (mOptionsStateChangeListener != null) { mOptionsStateChangeListener.onOptionsClosed(); } mExpandCollapseHandle.setContentDescription(mContext.getString(R.string.expand_handle)); announceForAccessibility(mContext.getString(R.string.print_options_collapsed)); if (mMoreOptionsButton.getVisibility() != View.GONE) { mMoreOptionsButton.setVisibility(View.INVISIBLE); } mDraggableContent.setVisibility(View.INVISIBLE); // If we change the scrim visibility the dimming is lagging // and is janky. Now it is there but transparent, doing nothing. mEmbeddedContentScrim.setOnClickListener(null); mEmbeddedContentScrim.setClickable(false); mExpandCollapseIcon.setBackgroundResource(R.drawable.ic_expand_more); } else { if (mMoreOptionsButton.getVisibility() != View.GONE) { mMoreOptionsButton.setVisibility(View.VISIBLE); } mDraggableContent.setVisibility(View.VISIBLE); } }
From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java
/** * Animates a view./*from w w w . j av a 2 s .c o m*/ * * @param v view to animate * @param initAlpha initial alpha * @param initTransX initial translation in the X * @param delay delay in ms * @param duration duration in ms * @param interpolator interpolator to be used, can be null * @param isIcon if {@code true}, this is the main icon being moved */ public void prepareAndAnimateView(final View v, float initAlpha, float initTransX, int delay, int duration, Interpolator interpolator, final boolean isIcon) { if (v != null && v.getWindowToken() != null) { v.setLayerType(View.LAYER_TYPE_HARDWARE, null); v.buildLayer(); v.setAlpha(initAlpha); v.setTranslationX(initTransX); v.animate().alpha(1f).translationX(0).setDuration(duration).setStartDelay(delay); if (interpolator != null) { v.animate().setInterpolator(interpolator); } v.animate().setListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { v.setLayerType(View.LAYER_TYPE_NONE, null); if (isIcon) { if (mShadowLayer != null) { mShadowLayer.setShadowsAlpha(1f); } onIntroAnimationFinished(); } } }); v.animate().start(); } }
From source file:mgks.os.webview.MainActivity.java
@SuppressLint({ "SetJavaScriptEnabled", "WrongViewCast" }) @Override/*from w w w . j a va2 s . c om*/ protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.w("READ_PERM = ", Manifest.permission.READ_EXTERNAL_STORAGE); Log.w("WRITE_PERM = ", Manifest.permission.WRITE_EXTERNAL_STORAGE); //Prevent the app from being started again when it is still alive in the background if (!isTaskRoot()) { finish(); return; } setContentView(R.layout.activity_main); asw_view = findViewById(R.id.msw_view); final SwipeRefreshLayout pullfresh = findViewById(R.id.pullfresh); if (ASWP_PULLFRESH) { pullfresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { pull_fresh(); pullfresh.setRefreshing(false); } }); asw_view.getViewTreeObserver() .addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() { @Override public void onScrollChanged() { if (asw_view.getScrollY() == 0) { pullfresh.setEnabled(true); } else { pullfresh.setEnabled(false); } } }); } else { pullfresh.setRefreshing(false); pullfresh.setEnabled(false); } if (ASWP_PBAR) { asw_progress = findViewById(R.id.msw_progress); } else { findViewById(R.id.msw_progress).setVisibility(View.GONE); } asw_loading_text = findViewById(R.id.msw_loading_text); Handler handler = new Handler(); //Launching app rating request if (ASWP_RATINGS) { handler.postDelayed(new Runnable() { public void run() { get_rating(); } }, 1000 * 60); //running request after few moments } //Getting basic device information get_info(); //Getting GPS location of device if given permission if (ASWP_LOCATION && !check_permission(1)) { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, loc_perm); } get_location(); //Webview settings; defaults are customized for best performance WebSettings webSettings = asw_view.getSettings(); if (!ASWP_OFFLINE) { webSettings.setJavaScriptEnabled(ASWP_JSCRIPT); } webSettings.setSaveFormData(ASWP_SFORM); webSettings.setSupportZoom(ASWP_ZOOM); webSettings.setGeolocationEnabled(ASWP_LOCATION); webSettings.setAllowFileAccess(true); webSettings.setAllowFileAccessFromFileURLs(true); webSettings.setAllowUniversalAccessFromFileURLs(true); webSettings.setUseWideViewPort(true); webSettings.setDomStorageEnabled(true); asw_view.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { return true; } }); asw_view.setHapticFeedbackEnabled(false); asw_view.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength) { if (!check_permission(2)) { ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE }, file_perm); } else { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.setMimeType(mimeType); String cookies = CookieManager.getInstance().getCookie(url); request.addRequestHeader("cookie", cookies); request.addRequestHeader("User-Agent", userAgent); request.setDescription(getString(R.string.dl_downloading)); request.setTitle(URLUtil.guessFileName(url, contentDisposition, mimeType)); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, URLUtil.guessFileName(url, contentDisposition, mimeType)); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); assert dm != null; dm.enqueue(request); Toast.makeText(getApplicationContext(), getString(R.string.dl_downloading2), Toast.LENGTH_LONG) .show(); } } }); if (Build.VERSION.SDK_INT >= 21) { getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark)); asw_view.setLayerType(View.LAYER_TYPE_HARDWARE, null); webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } else if (Build.VERSION.SDK_INT >= 19) { asw_view.setLayerType(View.LAYER_TYPE_HARDWARE, null); } asw_view.setVerticalScrollBarEnabled(false); asw_view.setWebViewClient(new Callback()); //Rendering the default URL aswm_view(ASWV_URL, false); asw_view.setWebChromeClient(new WebChromeClient() { //Handling input[type="file"] requests for android API 16+ public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { if (ASWP_FUPLOAD) { asw_file_message = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType(ASWV_F_TYPE); if (ASWP_MULFILE) { i.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } startActivityForResult(Intent.createChooser(i, getString(R.string.fl_chooser)), asw_file_req); } } //Handling input[type="file"] requests for android API 21+ public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { if (check_permission(2) && check_permission(3)) { if (ASWP_FUPLOAD) { if (asw_file_path != null) { asw_file_path.onReceiveValue(null); } asw_file_path = filePathCallback; Intent takePictureIntent = null; if (ASWP_CAMUPLOAD) { takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); if (takePictureIntent.resolveActivity(MainActivity.this.getPackageManager()) != null) { File photoFile = null; try { photoFile = create_image(); takePictureIntent.putExtra("PhotoPath", asw_cam_message); } catch (IOException ex) { Log.e(TAG, "Image file creation failed", ex); } if (photoFile != null) { asw_cam_message = "file:" + photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photoFile)); } else { takePictureIntent = null; } } } Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); if (!ASWP_ONLYCAM) { contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType(ASWV_F_TYPE); if (ASWP_MULFILE) { contentSelectionIntent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); } } Intent[] intentArray; if (takePictureIntent != null) { intentArray = new Intent[] { takePictureIntent }; } else { intentArray = new Intent[0]; } Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, getString(R.string.fl_chooser)); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); startActivityForResult(chooserIntent, asw_file_req); } return true; } else { get_file(); return false; } } //Getting webview rendering progress @Override public void onProgressChanged(WebView view, int p) { if (ASWP_PBAR) { asw_progress.setProgress(p); if (p == 100) { asw_progress.setProgress(0); } } } // overload the geoLocations permissions prompt to always allow instantly as app permission was granted previously public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) { if (Build.VERSION.SDK_INT < 23 || check_permission(1)) { // location permissions were granted previously so auto-approve callback.invoke(origin, true, false); } else { // location permissions not granted so request them ActivityCompat.requestPermissions(MainActivity.this, new String[] { Manifest.permission.ACCESS_FINE_LOCATION }, loc_perm); } } }); if (getIntent().getData() != null) { String path = getIntent().getDataString(); /* If you want to check or use specific directories or schemes or hosts Uri data = getIntent().getData(); String scheme = data.getScheme(); String host = data.getHost(); List<String> pr = data.getPathSegments(); String param1 = pr.get(0); */ aswm_view(path, false); } }
From source file:org.akop.ararat.view.CrosswordView.java
public CrosswordView(Context context, AttributeSet attrs) { super(context, attrs); if (!isInEditMode()) { setLayerType(View.LAYER_TYPE_HARDWARE, null); }/*from ww w.j ava 2 s . c o m*/ // Set drawing defaults Resources r = context.getResources(); DisplayMetrics dm = r.getDisplayMetrics(); int cellFillColor = NORMAL_CELL_FILL_COLOR; int cheatedCellFillColor = CHEATED_CELL_FILL_COLOR; int mistakeCellFillColor = MISTAKE_CELL_FILL_COLOR; int selectedWordFillColor = SELECTED_WORD_FILL_COLOR; int selectedCellFillColor = SELECTED_CELL_FILL_COLOR; int markedCellFillColor = MARKED_CELL_FILL_COLOR; int numberTextColor = NUMBER_TEXT_COLOR; int cellStrokeColor = CELL_STROKE_COLOR; int circleStrokeColor = CIRCLE_STROKE_COLOR; int answerTextColor = ANSWER_TEXT_COLOR; mScaledDensity = dm.scaledDensity; float numberTextSize = NUMBER_TEXT_SIZE * mScaledDensity; mAnswerTextSize = ANSWER_TEXT_SIZE * mScaledDensity; mCellSize = CELL_SIZE * dm.density; mNumberTextPadding = NUMBER_TEXT_PADDING * dm.density; mIsEditable = true; mInputMode = INPUT_MODE_KEYBOARD; mSkipOccupiedOnType = false; mSelectFirstUnoccupiedOnNav = true; mMaxBitmapSize = DEFAULT_MAX_BITMAP_DIMENSION; // Read supplied attributes if (attrs != null) { Resources.Theme theme = context.getTheme(); TypedArray a = theme.obtainStyledAttributes(attrs, R.styleable.CrosswordView, 0, 0); mCellSize = a.getDimension(R.styleable.CrosswordView_cellSize, mCellSize); mNumberTextPadding = a.getDimension(R.styleable.CrosswordView_numberTextPadding, mNumberTextPadding); numberTextSize = a.getDimension(R.styleable.CrosswordView_numberTextSize, numberTextSize); mAnswerTextSize = a.getDimension(R.styleable.CrosswordView_answerTextSize, mAnswerTextSize); answerTextColor = a.getColor(R.styleable.CrosswordView_answerTextColor, answerTextColor); cellFillColor = a.getColor(R.styleable.CrosswordView_defaultCellFillColor, cellFillColor); cheatedCellFillColor = a.getColor(R.styleable.CrosswordView_cheatedCellFillColor, cheatedCellFillColor); mistakeCellFillColor = a.getColor(R.styleable.CrosswordView_mistakeCellFillColor, mistakeCellFillColor); selectedWordFillColor = a.getColor(R.styleable.CrosswordView_selectedWordFillColor, selectedWordFillColor); selectedCellFillColor = a.getColor(R.styleable.CrosswordView_selectedCellFillColor, selectedCellFillColor); markedCellFillColor = a.getColor(R.styleable.CrosswordView_markedCellFillColor, markedCellFillColor); cellStrokeColor = a.getColor(R.styleable.CrosswordView_cellStrokeColor, cellStrokeColor); circleStrokeColor = a.getColor(R.styleable.CrosswordView_circleStrokeColor, circleStrokeColor); numberTextColor = a.getColor(R.styleable.CrosswordView_numberTextColor, numberTextColor); mIsEditable = a.getBoolean(R.styleable.CrosswordView_editable, mIsEditable); mSkipOccupiedOnType = a.getBoolean(R.styleable.CrosswordView_skipOccupiedOnType, mSkipOccupiedOnType); mSelectFirstUnoccupiedOnNav = a.getBoolean(R.styleable.CrosswordView_selectFirstUnoccupiedOnNav, mSelectFirstUnoccupiedOnNav); a.recycle(); } mRevealSetsCheatFlag = true; mMarkerSideLength = mCellSize * MARKER_TRIANGLE_LENGTH_FRACTION; // Init paints mCellFillPaint = new Paint(); mCellFillPaint.setColor(cellFillColor); mCellFillPaint.setStyle(Paint.Style.FILL); mCheatedCellFillPaint = new Paint(); mCheatedCellFillPaint.setColor(cheatedCellFillColor); mCheatedCellFillPaint.setStyle(Paint.Style.FILL); mMistakeCellFillPaint = new Paint(); mMistakeCellFillPaint.setColor(mistakeCellFillColor); mMistakeCellFillPaint.setStyle(Paint.Style.FILL); mSelectedWordFillPaint = new Paint(); mSelectedWordFillPaint.setColor(selectedWordFillColor); mSelectedWordFillPaint.setStyle(Paint.Style.FILL); mSelectedCellFillPaint = new Paint(); mSelectedCellFillPaint.setColor(selectedCellFillColor); mSelectedCellFillPaint.setStyle(Paint.Style.FILL); mMarkedCellFillPaint = new Paint(); mMarkedCellFillPaint.setColor(markedCellFillColor); mMarkedCellFillPaint.setStyle(Paint.Style.FILL); mCellStrokePaint = new Paint(); mCellStrokePaint.setColor(cellStrokeColor); mCellStrokePaint.setStyle(Paint.Style.STROKE); // mCellStrokePaint.setStrokeWidth(1); mCircleStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mCircleStrokePaint.setColor(circleStrokeColor); mCircleStrokePaint.setStyle(Paint.Style.STROKE); mCircleStrokePaint.setStrokeWidth(1); mNumberTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mNumberTextPaint.setColor(numberTextColor); mNumberTextPaint.setTextAlign(Paint.Align.CENTER); mNumberTextPaint.setTextSize(numberTextSize); // Compute number height mNumberTextPaint.getTextBounds("0", 0, "0".length(), mTempRect); mNumberTextHeight = mTempRect.height(); mNumberStrokePaint = new Paint(Paint.ANTI_ALIAS_FLAG); mNumberStrokePaint.setColor(cellFillColor); mNumberStrokePaint.setTextAlign(Paint.Align.CENTER); mNumberStrokePaint.setTextSize(numberTextSize); mNumberStrokePaint.setStyle(Paint.Style.STROKE); mNumberStrokePaint.setStrokeWidth(NUMBER_TEXT_STROKE_WIDTH * mScaledDensity); mAnswerTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG); mAnswerTextPaint.setColor(answerTextColor); mAnswerTextPaint.setTextSize(mAnswerTextSize); // Init rest of the values mCircleRadius = (mCellSize / 2) - mCircleStrokePaint.getStrokeWidth(); mPuzzleCells = EMPTY_CELLS; mPuzzleWidth = 0; mPuzzleHeight = 0; mAllowedChars = EMPTY_CHARS; mRenderScale = 0; mBitmapOffset = new PointF(); mCenteredOffset = new PointF(); mTranslationBounds = new RectF(); mScaleDetector = new ScaleGestureDetector(context, new ScaleListener()); mGestureDetector = new GestureDetector(context, new GestureListener()); mContentRect = new RectF(); mPuzzleRect = new RectF(); mBitmapPaint = new Paint(Paint.FILTER_BITMAP_FLAG); mScroller = new Scroller(context, null, true); mZoomer = new Zoomer(context); mUndoBuffer = new Stack<>(); setFocusableInTouchMode(mIsEditable && mInputMode != INPUT_MODE_NONE); setOnKeyListener(this); }
From source file:com.taobao.weex.ui.animation.WXAnimationModule.java
public static void startAnimation(WXSDKInstance mWXSDKInstance, WXComponent component, @NonNull WXAnimationBean animationBean, @Nullable String callback) { if (component == null) { return;// ww w .ja v a 2s . c om } if (component.getHostView() == null) { AnimationHolder holder = new AnimationHolder(animationBean, callback); component.postAnimation(holder); return; } try { Animator animator = createAnimator(animationBean, component.getHostView(), mWXSDKInstance.getViewPortWidth()); if (animator != null) { Animator.AnimatorListener animatorCallback = createAnimatorListener(mWXSDKInstance, callback); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) { component.getHostView().setLayerType(View.LAYER_TYPE_HARDWARE, null); } Interpolator interpolator = createTimeInterpolator(animationBean); if (animatorCallback != null) { animator.addListener(animatorCallback); } if (interpolator != null) { animator.setInterpolator(interpolator); } animator.setDuration(animationBean.duration); animator.start(); } } catch (RuntimeException e) { e.printStackTrace(); WXLogUtils.e("", e); } }
From source file:ch.gianulli.flashcards.ui.Flashcard.java
private void expandButtonBar() { mButtonBarShowing = true;/*from w w w. j ava2s .c o m*/ mButtonBar.setVisibility(View.VISIBLE); mButtonBar.setAlpha(0.0f); final int startingHeight = mCardView.getHeight(); final ViewTreeObserver observer = mCardView.getViewTreeObserver(); observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { @Override public boolean onPreDraw() { // We don't want to continue getting called for every listview drawing. if (observer.isAlive()) { observer.removeOnPreDrawListener(this); } final int endingHeight = mCardView.getHeight(); final int distance = endingHeight - startingHeight; mCardView.getLayoutParams().height = startingHeight; mCardView.requestLayout(); ValueAnimator heightAnimator = ValueAnimator.ofFloat(0f, 1f).setDuration(300); heightAnimator.setInterpolator(new DecelerateInterpolator()); heightAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animator) { Float value = (Float) animator.getAnimatedValue(); mCardView.getLayoutParams().height = (int) (value * distance + startingHeight); mCardView.requestLayout(); } }); heightAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mCardView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; } }); mButtonBar.setLayerType(View.LAYER_TYPE_HARDWARE, null); ObjectAnimator alphaAnimator = ObjectAnimator.ofFloat(mButtonBar, "alpha", 0.0f, 1.0f); alphaAnimator.setInterpolator(new DecelerateInterpolator()); alphaAnimator.setDuration(300); alphaAnimator.setStartDelay(100); AnimatorSet set = new AnimatorSet(); set.playTogether(heightAnimator, alphaAnimator); set.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationEnd(Animator animation) { mButtonBar.setLayerType(View.LAYER_TYPE_SOFTWARE, null); } }); set.start(); return false; } }); }
From source file:metro.k.cover.view.JazzyViewPager.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void manageLayer(View v, boolean enableHardware) { final int layerType = enableHardware ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE; if (layerType != v.getLayerType()) { v.setLayerType(layerType, null); }// w w w . j ava 2 s. co m }
From source file:com.android.deskclock.Utils.java
/** * For screensavers to dim the lights if necessary. *//*from w w w .j av a 2s . c o m*/ public static void dimClockView(boolean dim, View clockView) { Paint paint = new Paint(); paint.setColor(Color.WHITE); paint.setColorFilter(new PorterDuffColorFilter((dim ? 0x40FFFFFF : 0xC0FFFFFF), PorterDuff.Mode.MULTIPLY)); clockView.setLayerType(View.LAYER_TYPE_HARDWARE, paint); }
From source file:com.insalyon.les24heures.JazzyViewPager.JazzyViewPager.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void manageLayer(View v, boolean enableHardware) { if (!API_11)/* ww w. j a va 2s . c o m*/ return; int layerType = enableHardware ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE; if (layerType != v.getLayerType()) v.setLayerType(layerType, null); }