List of usage examples for android.view View getWidth
@ViewDebug.ExportedProperty(category = "layout") public final int getWidth()
From source file:com.battlelancer.seriesguide.ui.SeasonsFragment.java
@Override public void onListItemClick(ListView l, View view, int position, long id) { Intent intent = new Intent(getActivity(), EpisodesActivity.class); intent.putExtra(EpisodesActivity.InitBundle.SEASON_TVDBID, (int) id); ActivityCompat.startActivity(getActivity(), intent, ActivityOptionsCompat .makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight()).toBundle()); }
From source file:com.example.recyclerview.MyItemAnimator.java
private void animateRemoveImpl(final ViewHolder holder) { final View view = holder.itemView; final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); mRemoveAnimations.add(holder);/*from w w w .java2 s.c om*/ animation.setDuration(getRemoveDuration()).alpha(0).translationX(view.getWidth() / 2) .setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(View view) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(View view) { animation.setListener(null); ViewCompat.setTranslationX(view, 0); ViewCompat.setAlpha(view, 1); dispatchRemoveFinished(holder); mRemoveAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); }
From source file:com.brkc.traffic.ui.image.ImageListFragment.java
@TargetApi(VERSION_CODES.JELLY_BEAN) @Override//from ww w . j a va 2 s .c o m public void onItemClick(AdapterView<?> parent, View v, int position, long id) { Log.d(TAG, "v=" + v.getId() + ",id=" + id + ",position=" + position); final Intent i = new Intent(getActivity(), ImageDetailActivity.class); i.putExtra(ImageDetailActivity.EXTRA_IMAGE, (int) id); if (Utils.hasJellyBean()) { // makeThumbnailScaleUpAnimation() looks kind of ugly here as the loading spinner may // show plus the thumbnail image in GridView is cropped. so using // makeScaleUpAnimation() instead. ActivityOptions options = ActivityOptions.makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()); getActivity().startActivity(i, options.toBundle()); } else { startActivity(i); } }
From source file:com.app.laundry.tabs.lib.TabPageIndicator2.java
private void animateToTab(final int position) { final View tabView = mTabLayout.getChildAt(position); TabView new_tabView = (TabView) tabView; old_tab.setBackgroundResource(R.drawable.tab_unselected); new_tabView.setBackgroundResource(R.drawable.tab_selected); old_tab = new_tabView; if (mTabSelector != null) { removeCallbacks(mTabSelector);// ww w . j av a 2s . c o m } mTabSelector = new Runnable() { public void run() { final int scrollPos = tabView.getLeft() - (getWidth() - tabView.getWidth()) / 2; smoothScrollTo(scrollPos, 0); mTabSelector = null; } }; post(mTabSelector); }
From source file:com.chenli.recycler.MyItemAnimator.java
private void animateRemoveImpl(final ViewHolder holder) { final View view = holder.itemView; final ViewPropertyAnimatorCompat animation = ViewCompat.animate(view); mRemoveAnimations.add(holder);/*from w ww.java 2 s. c o m*/ animation.setDuration(getRemoveDuration())// .translationX(view.getWidth()).setListener(new VpaListenerAdapter() { @Override public void onAnimationStart(View view) { dispatchRemoveStarting(holder); } @Override public void onAnimationEnd(View view) { animation.setListener(null); ViewCompat.setTranslationX(view, 0);//?? dispatchRemoveFinished(holder); mRemoveAnimations.remove(holder); dispatchFinishedWhenDone(); } }).start(); }
From source file:com.example.alyshia.customsimplelauncher.MainActivity.java
private void handlepicker() { View content = getWindow().findViewById(Window.ID_ANDROID_CONTENT); Log.d("DISPLAY", content.getWidth() + " x " + content.getHeight()); Display display = getWindowManager().getDefaultDisplay(); int aspect_x = content.getWidth(); int aspect_y = content.getHeight(); //enable gallary if disabled edm = (EnterpriseDeviceManager) getSystemService(EnterpriseDeviceManager.ENTERPRISE_POLICY_SERVICE); ApplicationPolicy appPolicy = edm.getApplicationPolicy(); boolean success = appPolicy.removePackagesFromPreventStartBlackList(gallery); if (success) { Log.d(TAG, "enabling back gallery successful"); Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); photoPickerIntent.setType("image/*"); photoPickerIntent.putExtra("crop", "true"); photoPickerIntent.putExtra("aspectX", aspect_x); photoPickerIntent.putExtra("aspectY", aspect_y); photoPickerIntent.putExtra("outputX", aspect_x); photoPickerIntent.putExtra("outputY", aspect_y); photoPickerIntent.putExtra(MediaStore.EXTRA_OUTPUT, getTempUri()); photoPickerIntent.putExtra("return-data", true); photoPickerIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); startActivityForResult(photoPickerIntent, REQ_CODE_PICK_IMAGE); } else {//from w ww . j a v a 2 s. co m Log.d(TAG, "enabling back gallery UNsuccessful"); } }
From source file:android.support.v17.leanback.widget.AbstractMediaItemPresenter.java
/** * Each media item row can have multiple focusable elements; the details on the left and a set * of optional custom actions on the right. * The selector is a highlight that moves to highlight to cover whichever views is in focus. * * @param selectorView the selector view used to highlight an individual element within a row. * @param focusChangedView The component within the media row whose focus got changed. * @param layoutAnimator the ValueAnimator producing animation frames for the selector's width * and x-translation, generated by this method and stored for the each * {@link ViewHolder}. * @param isDetails Whether the changed-focused view is for a media item details (true) or * an action (false).//from www . j a v a 2s .c om */ private static ValueAnimator updateSelector(final View selectorView, View focusChangedView, ValueAnimator layoutAnimator, boolean isDetails) { int animationDuration = focusChangedView.getContext().getResources() .getInteger(android.R.integer.config_shortAnimTime); DecelerateInterpolator interpolator = new DecelerateInterpolator(); int layoutDirection = ViewCompat.getLayoutDirection(selectorView); if (!focusChangedView.hasFocus()) { // if neither of the details or action views are in focus (ie. another row is in focus), // animate the selector out. selectorView.animate().cancel(); selectorView.animate().alpha(0f).setDuration(animationDuration).setInterpolator(interpolator).start(); // keep existing layout animator return layoutAnimator; } else { // cancel existing layout animator if (layoutAnimator != null) { layoutAnimator.cancel(); layoutAnimator = null; } float currentAlpha = selectorView.getAlpha(); selectorView.animate().alpha(1f).setDuration(animationDuration).setInterpolator(interpolator).start(); final ViewGroup.MarginLayoutParams lp = (ViewGroup.MarginLayoutParams) selectorView.getLayoutParams(); ViewGroup rootView = (ViewGroup) selectorView.getParent(); sTempRect.set(0, 0, focusChangedView.getWidth(), focusChangedView.getHeight()); rootView.offsetDescendantRectToMyCoords(focusChangedView, sTempRect); if (isDetails) { if (layoutDirection == View.LAYOUT_DIRECTION_RTL) { sTempRect.right += rootView.getHeight(); sTempRect.left -= rootView.getHeight() / 2; } else { sTempRect.left -= rootView.getHeight(); sTempRect.right += rootView.getHeight() / 2; } } final int targetLeft = sTempRect.left; final int targetWidth = sTempRect.width(); final float deltaWidth = lp.width - targetWidth; final float deltaLeft = lp.leftMargin - targetLeft; if (deltaLeft == 0f && deltaWidth == 0f) { // no change needed } else if (currentAlpha == 0f) { // change selector to the proper width and marginLeft without animation. lp.width = targetWidth; lp.leftMargin = targetLeft; selectorView.requestLayout(); } else { // animate the selector to the proper width and marginLeft. layoutAnimator = ValueAnimator.ofFloat(0f, 1f); layoutAnimator.setDuration(animationDuration); layoutAnimator.setInterpolator(interpolator); layoutAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator valueAnimator) { // Set width to the proper width for this animation step. float fractionToEnd = 1f - valueAnimator.getAnimatedFraction(); lp.leftMargin = Math.round(targetLeft + deltaLeft * fractionToEnd); lp.width = Math.round(targetWidth + deltaWidth * fractionToEnd); selectorView.requestLayout(); } }); layoutAnimator.start(); } return layoutAnimator; } }
From source file:cn.nekocode.camerafilter.MainActivity.java
void setupCameraPreviewView() { renderer = new CameraRenderer(this); textureView = (TextureView) findViewById(R.id.textureView); assert textureView != null; textureView.setSurfaceTextureListener(renderer); // Show original frame when touch the view textureView.setOnTouchListener(new View.OnTouchListener() { @Override/*from ww w. j av a 2 s. c o m*/ public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: renderer.setSelectedFilter(R.id.filter0); break; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: renderer.setSelectedFilter(filterId); break; } return true; } }); textureView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() { @Override public void onLayoutChange(View v, int left, int top, int right, int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) { renderer.onSurfaceTextureSizeChanged(null, v.getWidth(), v.getHeight()); } }); }
From source file:com.raspi.chatapp.ui.chatting.SendImageFragment.java
private boolean isViewVisible(HorizontalScrollView scrollView, View view) { Rect scrollBounds = new Rect(); scrollView.getDrawingRect(scrollBounds); float vLeft = view.getLeft(); float vRight = view.getWidth() + vLeft; return scrollBounds.left < vLeft && scrollBounds.right > vRight; }
From source file:com.pitchedapps.primenumbercalculator.Calculator.java
License:asdf
void enterReveal(View view) { // previously invisible view final View myView = view; // get the final radius for the clipping circle int finalRadius = Math.max(myView.getWidth(), myView.getHeight()); // create the animator for this view (the start radius is zero) Animator anim = ViewAnimationUtils.createCircularReveal(myView, x, y, 0, finalRadius).setDuration(600); // make the view visible and start the animation myView.setVisibility(View.VISIBLE); anim.start();//from ww w . jav a 2 s. c o m }