List of usage examples for android.view View getWidth
@ViewDebug.ExportedProperty(category = "layout") public final int getWidth()
From source file:Main.java
public static Animator createCircularShowAnimator(final View view) { if (view.getVisibility() == View.VISIBLE || view.getWindowToken() == null) return null; // get the center for the clipping circle int cx = (view.getLeft() + view.getRight()) / 2; int cy = (view.getTop() + view.getBottom()) / 2; // get the final radius for the clipping circle int finalRadius = view.getWidth(); // create and start the animator for this view // (the start radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(view, cx, cy, 0, finalRadius); anim.addListener(new AnimatorListenerAdapter() { @Override//from w ww. j a v a 2 s. c om public void onAnimationStart(Animator animation) { super.onAnimationStart(animation); view.setVisibility(View.VISIBLE); } }); return anim; }
From source file:Main.java
public static Bitmap createBitmapFromView(View view) { if (view instanceof ImageView) { Drawable drawable = ((ImageView) view).getDrawable(); if (drawable != null && drawable instanceof BitmapDrawable) { return ((BitmapDrawable) drawable).getBitmap(); }/*from w w w . ja v a 2 s . c o m*/ } view.clearFocus(); Bitmap bitmap = createBitmapSafely(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888, 1); if (bitmap != null) { synchronized (sCanvas) { Canvas canvas = sCanvas; canvas.setBitmap(bitmap); view.draw(canvas); canvas.setBitmap(null); } } return bitmap; }
From source file:Main.java
private static ViewGroup.MarginLayoutParams getOrCreateMarginLayoutParams(View view) { ViewGroup.LayoutParams lp = view.getLayoutParams(); if (lp != null) { if (lp instanceof ViewGroup.MarginLayoutParams) { return (ViewGroup.MarginLayoutParams) lp; } else {//w w w . ja v a 2 s .c o m return new ViewGroup.MarginLayoutParams(lp); } } else { return new ViewGroup.MarginLayoutParams(view.getWidth(), view.getHeight()); } }
From source file:Main.java
public static void shrinkToLeft(FragmentActivity activity, View view, AnimationListener listener) { DisplayMetrics displaymetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int screenHeight = displaymetrics.heightPixels; int screenWidth = displaymetrics.widthPixels; AnimationSet animation = new AnimationSet(true); float pivotX = view.getWidth() / 2; float pivotY = view.getHeight() / 2; ScaleAnimation anim = new ScaleAnimation(1f, 0.8f, 1f, 0.8f, pivotX, pivotY); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(200);// w w w .jav a2 s . c o m anim.setStartOffset(200); //anim.setFillAfter(true); animation.addAnimation(anim); TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) -(screenWidth - view.getWidth()), 0.0f, 0.0f); anim.setInterpolator(new LinearInterpolator()); animTrans.setDuration(400); //animTrans.setStartOffset(300); animation.addAnimation(animTrans); if (listener != null) animation.setAnimationListener(listener); view.startAnimation(animation); }
From source file:Main.java
public static void enlargeToRight(FragmentActivity activity, View view, AnimationListener listener) { DisplayMetrics displaymetrics = new DisplayMetrics(); activity.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int screenHeight = displaymetrics.heightPixels; int screenWidth = displaymetrics.widthPixels; AnimationSet animation = new AnimationSet(true); float pivotX = view.getWidth() / 2; float pivotY = view.getHeight() / 2; ScaleAnimation anim = new ScaleAnimation(0.8f, 1f, 0.8f, 1f, pivotX, pivotY); anim.setInterpolator(new LinearInterpolator()); anim.setDuration(200);/*from ww w. j a v a2 s. c om*/ anim.setStartOffset(200); //anim.setFillAfter(true); animation.addAnimation(anim); TranslateAnimation animTrans = new TranslateAnimation(0.0f, (float) (screenWidth - view.getWidth()), 0.0f, 0.0f); anim.setInterpolator(new LinearInterpolator()); animTrans.setDuration(400); //animTrans.setStartOffset(300); animation.addAnimation(animTrans); if (listener != null) animation.setAnimationListener(listener); view.startAnimation(animation); }
From source file:com.simas.vc.helpers.Utils.java
public static Bitmap screenshot2(View v) { Bitmap b = Bitmap.createBitmap(v.getWidth(), v.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(b); v.draw(canvas);//from w ww .j a v a 2s . com return b; }
From source file:Main.java
/** * Adds a rectangular outline to a view. This can be useful when you want to add a shadow * to a transparent view. See b/16856049. * @param view view that the outline is added to * @param res The resources file./*from w w w . j a v a 2s . c om*/ */ public static void addRectangularOutlineProvider(View view, Resources res) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { ViewOutlineProvider rectOutlineProvider = new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { outline.setRect(0, 0, view.getWidth(), view.getHeight()); } } }; view.setOutlineProvider(rectOutlineProvider); } }
From source file:Main.java
@SuppressLint("NewApi") public static void revealView(View toBeRevealed, View frame) { try {/* ww w . java 2s . com*/ if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { // get the center for the clipping circle int cx = (frame.getLeft() + frame.getRight()) / 2; int cy = (frame.getTop() + frame.getBottom()) / 2; // get the final radius for the clipping circle int finalRadius = Math.max(frame.getWidth(), frame.getHeight()); // create the animator for this view (the start radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(toBeRevealed, cx, cy, 0, finalRadius); // make the view visible and start the animation toBeRevealed.setVisibility(View.VISIBLE); anim.start(); } else { toBeRevealed.setVisibility(View.VISIBLE); } } catch (Exception e) { e.printStackTrace(); } }
From source file:Main.java
@SuppressLint("NewApi") public static void revealView(View toBeRevealed, View frame) { try {//w w w . j av a2 s . c o m if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { // get the center for the clipping circle int cx = (frame.getLeft() + frame.getRight()) / 2; int cy = (frame.getTop() + frame.getBottom()) / 2; // get the final radius for the clipping circle int finalRadius = Math.max(frame.getWidth(), frame.getHeight()); Log.v("INFO", "Radius: " + finalRadius); // create the animator for this view (the start radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(toBeRevealed, cx, cy, 0, finalRadius); // make the view visible and start the animation toBeRevealed.setVisibility(View.VISIBLE); anim.start(); } else { toBeRevealed.setVisibility(View.VISIBLE); } } catch (Exception e) { e.printStackTrace(); } }
From source file:com.camnter.easygank.views.PictureActivity.java
public static void startActivityByActivityOptionsCompat(Activity activity, String url, String title, View view) { Intent intent = createIntent(activity, url, title); ActivityOptionsCompat activityOptionsCompat = ActivityOptionsCompat.makeScaleUpAnimation(view, view.getWidth() / 2, view.getHeight() / 2, view.getWidth(), view.getHeight()); try {/* w w w. j av a 2 s .c o m*/ ActivityCompat.startActivity(activity, intent, activityOptionsCompat.toBundle()); } catch (IllegalArgumentException e) { e.printStackTrace(); startActivity(activity, url, title); } }