List of usage examples for android.view View getWidth
@ViewDebug.ExportedProperty(category = "layout") public final int getWidth()
From source file:com.example.toolbardemo.Fragment.ClippingViewFragment.java
private void clippingView() { ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() { @Override//from w w w .ja v a 2s . c om public void getOutline(View view, Outline outline) { outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), 10); } }; ViewOutlineProvider viewOutlineProvider1 = new ViewOutlineProvider() { @Override public void getOutline(View view, Outline outline) { outline.setRoundRect(0, 0, view.getWidth(), view.getHeight(), view.getHeight() / 2); } }; tv1.setOutlineProvider(viewOutlineProvider); tv2.setOutlineProvider(viewOutlineProvider1); }
From source file:com.aran.bang.widget.BaseTransformer.java
/** * Called each {@link #transformPage(View, float)} before {{@link #onTransform(View, float)} is called. * * @param view//ww w . j av a2s.c o m * @param position */ protected void onPreTransform(View view, float position) { final float width = view.getWidth(); view.setRotationX(0); view.setRotationY(0); view.setRotation(0); view.setScaleX(1); view.setScaleY(1); view.setPivotX(0); view.setPivotY(0); view.setTranslationY(0); view.setTranslationX(isPagingEnabled() ? 0f : -width * position); if (hideOffscreenPages()) { view.setAlpha(position <= -1f || position >= 1f ? 0f : 1f); } else { view.setAlpha(1f); } }
From source file:com.example.android.supportv4.content.FileProviderExample.java
/** * Save thumbnail of given {@link View} to {@link File}. *//*from ww w . j a va 2 s .co m*/ private void saveThumbnail(View view, File file) { final Bitmap bitmap = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888); final Canvas canvas = new Canvas(bitmap); view.draw(canvas); try { final OutputStream os = new FileOutputStream(file); try { bitmap.compress(Bitmap.CompressFormat.PNG, 100, os); } finally { os.close(); } } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.alexandrepiveteau.library.tutorial.ParallaxPagerTransformer.java
public void transformPage(View view, float position) { int pageWidth = view.getWidth(); if (position < -1) { // This page is way off-screen to the left. view.setAlpha(1);/*from w w w.j ava 2 s .c om*/ } else if (position <= 1 && mViewsToParallax != null) { // [-1,1] for (ParallaxTransformInformation parallaxTransformInformation : mViewsToParallax) { applyParallaxEffect(view, position, pageWidth, parallaxTransformInformation, position > 0); } } else { // This page is way off-screen to the right. view.setAlpha(1); } }
From source file:com.andrewsummers.otashu.DepthPageTransformer.java
/** * transformPage used to apply a custom transformation (animation) to page view scrolling. * //from w w w.j a v a 2 s. c o m * @param view Incoming view. * @param position Current position of page relative to current "front and center" page. As per * the official ViewPager documentation, possible values are: -1 is one page position * to the left 0 is front and center. 1 is one page position to the right */ public void transformPage(View view, float position) { int pageWidth = view.getWidth(); // if application touch feedback setting is set, enable touch feedback if (pref_touch_feedback_enabled) { view.setHapticFeedbackEnabled(true); view.performHapticFeedback(HapticFeedbackConstants.VIRTUAL_KEY, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); } // current page setting: [-Infinity, -1) if (position < -1) { // this page is way off-screen to the left view.setAlpha(0); } // current page setting: [-1, 0] else if (position <= 0) { // use the default slide transition when moving to the left page view.setAlpha(1); // view.setHapticFeedbackEnabled(hapticFeedbackEnabled); view.setTranslationY(pageWidth * position); view.setScaleX(1); view.setScaleY(1); } // current page setting: (0, 1) else if (position <= 1) { // fade page out view.setAlpha(1 - position); // counteract the default slide transition view.setTranslationY(pageWidth * -position); // scale the page down (between MIN_SCALE and 1) float scaleFactor = MIN_SCALE + (1 - MIN_SCALE) * (1 - Math.abs(position)); view.setScaleX(scaleFactor); view.setScaleY(scaleFactor); } // current page setting: (1, +Infinity] else { // this page is way off-screen to the right view.setAlpha(0); } }
From source file:com.andremion.heroes.ui.util.PagerSharedElementCallback.java
private void forceSharedElementLayout(View view) { int widthSpec = View.MeasureSpec.makeMeasureSpec(view.getWidth(), View.MeasureSpec.EXACTLY); int heightSpec = View.MeasureSpec.makeMeasureSpec(view.getHeight(), View.MeasureSpec.EXACTLY); view.measure(widthSpec, heightSpec); view.layout(view.getLeft(), view.getTop(), view.getRight(), view.getBottom()); }
From source file:cn.edu.zucc.list.FabAnimation.MorphDialogToFab.java
@Override public void captureEndValues(TransitionValues transitionValues) { super.captureEndValues(transitionValues); final View view = transitionValues.view; if (view.getWidth() <= 0 || view.getHeight() <= 0) { return;// www .ja va 2s . c om } transitionValues.values.put(PROPERTY_COLOR, ContextCompat.getColor(view.getContext(), R.color.fab_background_color)); transitionValues.values.put(PROPERTY_CORNER_RADIUS, view.getHeight() / 2);//view.getHeight() / 2 }
From source file:cn.edu.zucc.list.FabAnimation.MorphDialogToFab.java
@Override public void captureStartValues(TransitionValues transitionValues) { super.captureStartValues(transitionValues); final View view = transitionValues.view; if (view.getWidth() <= 0 || view.getHeight() <= 0) { return;/*from ww w . j a v a2 s. c o m*/ } transitionValues.values.put(PROPERTY_COLOR, ContextCompat.getColor(view.getContext(), R.color.dialog_background_color)); transitionValues.values.put(PROPERTY_CORNER_RADIUS, view.getResources().getDimensionPixelSize(R.dimen.dialog_corners)); }
From source file:com.cesards.samples.cropimageview.ABaseTransformer.java
/** * Called each {@link #transformPage(android.view.View, float)} before {{@link #onTransform(android.view.View, * float)}.// w ww .j a v a 2s . c o m * <p> * The default implementation attempts to reset all view properties. This is useful when toggling transforms that do * not modify the same page properties. For instance changing from a transformation that applies rotation to a * transformation that fades can inadvertently leave a fragment stuck with a rotation or with some degree of applied * alpha. * * @param page Apply the transformation to this page * @param position Position of page relative to the current front-and-center position of the pager. 0 is front and * center. 1 is one full page position to the right, and -1 is one page position to the left. */ protected void onPreTransform(View page, float position) { final float width = page.getWidth(); page.setRotationX(0); page.setRotationY(0); page.setRotation(0); page.setScaleX(1); page.setScaleY(1); page.setPivotX(0); page.setPivotY(0); page.setTranslationY(0); page.setTranslationX(isPagingEnabled() ? 0f : -width * position); if (hideOffscreenPages()) { page.setAlpha(position <= -1f || position >= 1f ? 0f : 1f); } else { page.setAlpha(1f); } }
From source file:cn.edu.zucc.list.FabAnimation.MorphFabToDialog.java
@Override public void captureStartValues(TransitionValues transitionValues) { super.captureStartValues(transitionValues); final View view = transitionValues.view; if (view.getWidth() <= 0 || view.getHeight() <= 0) { return;/* w ww.j a v a 2 s . c o m*/ } transitionValues.values.put(PROPERTY_COLOR, ContextCompat.getColor(view.getContext(), R.color.fab_background_color)); transitionValues.values.put(PROPERTY_CORNER_RADIUS, view.getHeight() / 2);//view.getHeight() / 2 }