List of usage examples for android.view View getAlpha
@ViewDebug.ExportedProperty(category = "drawing") public float getAlpha()
From source file:Main.java
public static void animHide(final View v) { animHide(v, 300, v.getAlpha(), 0, true); }
From source file:Main.java
public static Bitmap convertViewToBitmap(View comBitmap, int width, int height) { Bitmap bitmap = null;/* ww w .j a va2 s. c om*/ if (comBitmap != null) { comBitmap.clearFocus(); comBitmap.setPressed(false); boolean willNotCache = comBitmap.willNotCacheDrawing(); comBitmap.setWillNotCacheDrawing(false); // Reset the drawing cache background color to fully transparent // for the duration of this operation int color = comBitmap.getDrawingCacheBackgroundColor(); comBitmap.setDrawingCacheBackgroundColor(0); float alpha = comBitmap.getAlpha(); comBitmap.setAlpha(1.0f); if (color != 0) { comBitmap.destroyDrawingCache(); } int widthSpec = View.MeasureSpec.makeMeasureSpec(width, View.MeasureSpec.EXACTLY); int heightSpec = View.MeasureSpec.makeMeasureSpec(height, View.MeasureSpec.EXACTLY); comBitmap.measure(widthSpec, heightSpec); comBitmap.layout(0, 0, width, height); comBitmap.buildDrawingCache(); Bitmap cacheBitmap = comBitmap.getDrawingCache(); if (cacheBitmap == null) { Log.e("view.ProcessImageToBlur", "failed getViewBitmap(" + comBitmap + ")", new RuntimeException()); return null; } bitmap = Bitmap.createBitmap(cacheBitmap); // Restore the view comBitmap.setAlpha(alpha); comBitmap.destroyDrawingCache(); comBitmap.setWillNotCacheDrawing(willNotCache); comBitmap.setDrawingCacheBackgroundColor(color); } return bitmap; }
From source file:org.onebusaway.android.util.UIUtils.java
/** * Shows a view, using animation if the platform supports it * * @param v View to show * @param animationDuration duration of animation *///ww w. ja v a 2 s . c o m @TargetApi(14) public static void showViewWithAnimation(final View v, int animationDuration) { // If we're on a legacy device, show the view without the animation if (!canAnimateViewModern()) { showViewWithoutAnimation(v); return; } if (v.getVisibility() == View.VISIBLE && v.getAlpha() == 1) { // View is already visible and not transparent, return without doing anything return; } v.clearAnimation(); if (canCancelAnimation()) { v.animate().cancel(); } if (v.getVisibility() != View.VISIBLE) { // Set the content view to 0% opacity but visible, so that it is visible // (but fully transparent) during the animation. v.setAlpha(0f); v.setVisibility(View.VISIBLE); } // Animate the content view to 100% opacity, and clear any animation listener set on the view. v.animate().alpha(1f).setDuration(animationDuration).setListener(null); }
From source file:com.carver.paul.truesight.Ui.MainActivity.java
protected void hideClearFab() { View fab = findViewById(R.id.fab_clear); if (fab.getAlpha() != 0f) { fab.animate().alpha(0f).setDuration(150); }//from w w w. ja v a 2s . c o m }
From source file:org.onebusaway.android.util.UIUtils.java
/** * Prints View visibility information to the log for debugging purposes * * @param v View to log visibility information for *///from ww w .j ava 2s. co m @TargetApi(12) public static void logViewVisibility(View v) { if (v != null) { if (v.getVisibility() == View.VISIBLE) { Log.d(TAG, v.getContext().getResources().getResourceEntryName(v.getId()) + " is visible"); if (UIUtils.canAnimateViewModern()) { Log.d(TAG, v.getContext().getResources().getResourceEntryName(v.getId()) + " alpha - " + v.getAlpha()); } } else if (v.getVisibility() == View.INVISIBLE) { Log.d(TAG, v.getContext().getResources().getResourceEntryName(v.getId()) + " is INVISIBLE"); } else if (v.getVisibility() == View.GONE) { Log.d(TAG, v.getContext().getResources().getResourceEntryName(v.getId()) + " is GONE"); } else { Log.d(TAG, v.getContext().getResources().getResourceEntryName(v.getId()) + ".getVisibility() - " + v.getVisibility()); } } }
From source file:com.kozhevin.example.carousel.CarouselItemAnimator.java
private void animateAlhaRemove(final View pView, final ViewHolder pHolder) { if (pView.getAlpha() > 0.8f) { ViewCompat.animate(pView).setDuration(getRemoveDuration()).alpha(0) .setListener(new VpaListenerAdapter() { @Override//from w ww . j a v a 2 s . co m public void onAnimationEnd(View pView) { afterAnimatedAlfaRemove(pView, pHolder); } }).start(); } else { afterAnimatedAlfaRemove(pView, pHolder); } }
From source file:fr.outadev.skinswitch.DetailActivity.java
/** * Creates and displays the skin previews in the containers. */// w ww . j a v a 2s . co m private void setupSkinPreviews() { final ImageView img_skin_preview_front = (ImageView) findViewById(R.id.skin_preview_front); final ImageView img_skin_preview_back = (ImageView) findViewById(R.id.skin_preview_back); (new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... voids) { try { return skin.getFrontSkinPreview(DetailActivity.this); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Bitmap bmp) { if (bmp != null) { img_skin_preview_front.setImageBitmap(bmp); colorizeInterface(bmp); } (new AsyncTask<Void, Void, Bitmap>() { @Override protected Bitmap doInBackground(Void... voids) { try { return skin.getBackSkinPreview(DetailActivity.this); } catch (FileNotFoundException e) { e.printStackTrace(); } return null; } @Override protected void onPostExecute(Bitmap bmp) { if (bmp != null) { img_skin_preview_back.setImageBitmap(bmp); } } }).execute(); } }).execute(); img_skin_preview_front.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (view.getAlpha() == 1.0) { Utils.crossfade(img_skin_preview_front, img_skin_preview_back, animTime); } } }); img_skin_preview_back.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (view.getAlpha() == 1.0) { Utils.crossfade(img_skin_preview_back, img_skin_preview_front, animTime); } } }); }
From source file:com.mad.splitlist.util.DividerItemDecoration.java
@Override public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) { final int offset = (int) (mPaint.getStrokeWidth() / DIVIDE_OFFSET); for (int i = 0; i < parent.getChildCount(); i++) { final View view = parent.getChildAt(i); final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) view.getLayoutParams(); final int position = params.getViewAdapterPosition(); // Draw separator using paint. if (position < state.getItemCount()) { // apply alpha to support animations mPaint.setAlpha((int) (view.getAlpha() * mAlpha)); float positionY = view.getBottom() + offset + view.getTranslationY(); // do the drawing c.drawLine(view.getLeft() + view.getTranslationX(), positionY, view.getRight() + view.getTranslationX(), positionY, mPaint); }//from ww w.j a v a 2s.co m } }
From source file:com.carver.paul.truesight.Ui.MainActivity.java
protected void showClearFab() { View fab = findViewById(R.id.fab_clear); fab.setVisibility(View.VISIBLE); if (fab.getAlpha() != 1f) { fab.animate().alpha(1f).setDuration(150).setStartDelay(50); }/*from w w w . ja v a 2 s .c o m*/ }
From source file:moe.yukinoneko.gcomic.module.gallery.external.ExternalGalleryActivity.java
public void toggleSystemUi() { boolean isShown = mToolbar.getAlpha() == 1.0f; ViewCompat.animate(mToolbar).alpha(isShown ? 0.0f : 1.0f).start(); ViewCompat.animate(bottomBar).alpha(isShown ? 0.0f : 1.0f) .setListener(new ViewPropertyAnimatorListenerAdapter() { @Override/*www.ja v a 2 s . c o m*/ public void onAnimationStart(View view) { super.onAnimationStart(view); if (view.isShown()) { return; } view.setVisibility(View.VISIBLE); } @Override public void onAnimationEnd(View view) { super.onAnimationEnd(view); if (view.getAlpha() == 1.0f) { return; } view.setVisibility(View.INVISIBLE); } }).start(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mDecorView.setSystemUiVisibility(isShown ? FULL_SCREEN_FLAG : NOT_FULL_SCREEN_FLAG); } }