Java Code Examples for android.widget.ImageView#setTranslationY()
The following examples show how to use
android.widget.ImageView#setTranslationY() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ScreenshotFragment.java From DGameDetail with Apache License 2.0 | 6 votes |
/** * 恢复 * * @param img */ private void resumeRotation(ImageView img, boolean useAnim) { int w = AndroidUtils.getWindowWidth(getActivity()), h = AndroidUtils.getWindowHeight(getActivity()); int iw = img.getMeasuredWidth(), ih = img.getMeasuredHeight(); if (useAnim) { ObjectAnimator move = ObjectAnimator.ofFloat(img, "translationY", (h - ih) / 2f, 0); move.setDuration(400); ObjectAnimator scaleX = ObjectAnimator.ofFloat(img, "scaleX", (float) h / iw, 1.0f); ObjectAnimator scaleY = ObjectAnimator.ofFloat(img, "scaleY", (float) w / ih, 1.0f); ObjectAnimator rotation = ObjectAnimator.ofFloat(img, "rotation", 90f, 0f); AnimatorSet set = new AnimatorSet(); set.play(scaleX).with(scaleY).with(rotation).with(move); set.setDuration(600); set.start(); } else { img.setTranslationY(0f); img.setScaleX(1.0f); img.setScaleY(1.0f); img.setRotation(0f); } }
Example 2
Source File: SparkleDemoActivity.java From SparkleMotion with MIT License | 6 votes |
/** * Build the fourth page Decors: a sun that slides down as the ViewPager scrolls. */ private void buildDecorForPage3(SparkleViewPagerLayout parent, SparkleMotion sparkleMotion) { ImageView sunImageView = new ImageView(parent.getContext()); sunImageView.setImageResource(R.drawable.sun); int sunSize = getResources().getDimensionPixelSize(R.dimen.icon_sun_size); FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(sunSize, sunSize); sunImageView.setLayoutParams(lp); sunImageView.setTranslationY(-sunSize); sunImageView.setTranslationX(sunSize); Decor decor = new Decor.Builder(sunImageView).setPage(Page.pageRange(2, 4)).withLayer().build(); TranslationAnimation translationAnimation = new TranslationAnimation(Page.singlePage(2), sunSize, -sunSize, -sunSize / 3f, -sunSize / 3f, true); sparkleMotion.animate(translationAnimation).on(decor); }
Example 3
Source File: BossTransferView.java From BlogDemo with Apache License 2.0 | 6 votes |
private void init() { LayoutInflater.from(getContext()).inflate(R.layout.layout_boss_transfer, this); mImg = (ImageView) findViewById(R.id.img); mTemp = findViewById(R.id.line); // mPb = (ProgressBar) findViewById(R.id.progress); mPb = (ImageView) findViewById(R.id.progress); mHandleView.getLocationInWindow(mLocation); int sbh = Util.getStatusBarHeight(getContext()); mImg.setTranslationY(mLocation[1] - sbh); mTemp.setTranslationY(mLocation[1] + mImg.getMeasuredHeight() / 2 + sbh); mPb.setVisibility(GONE); Bitmap bm = getViewImg(mHandleView); if (bm != null) { mImg.setImageBitmap(getViewImg(mHandleView)); } AnimationDrawable ad = new AnimationDrawable(); ad.addFrame(getDrawable(R.mipmap.icon_refresh_left), 200); ad.addFrame(getDrawable(R.mipmap.icon_refresh_center), 200); ad.addFrame(getDrawable(R.mipmap.icon_refresh_right), 200); mPb.setImageDrawable(ad); ad.setOneShot(false); ad.start(); }
Example 4
Source File: MainActivity.java From ParallaxHeaderViewPager with MIT License | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); initValues(); mTopImage = (ImageView) findViewById(R.id.image); mViewPager = (ViewPager) findViewById(R.id.view_pager); mNavigBar = (SlidingTabLayout) findViewById(R.id.navig_tab); mHeader = findViewById(R.id.header); if (savedInstanceState != null) { mTopImage.setTranslationY(savedInstanceState.getFloat(IMAGE_TRANSLATION_Y)); mHeader.setTranslationY(savedInstanceState.getFloat(HEADER_TRANSLATION_Y)); } setupAdapter(); }
Example 5
Source File: CrossMoveAnimMode.java From ECardFlow with MIT License | 5 votes |
@Override public void transformPage(ImageView ivBg, float position, int direction) { ivBg.setScaleX(mScale); ivBg.setScaleY(mScale); float totalMoveWidth = ivBg.getWidth() * ((mScale - 1) / 2); int lastPosition = Math.round(position); float mFraction; if (lastPosition % 2 == 0) { mFraction = -1 * (float) Math.sin(Math.PI * position); } else { mFraction = (float) Math.sin(Math.PI * position); } ivBg.setTranslationY(totalMoveWidth * mFraction); }
Example 6
Source File: SparkleDemoActivity.java From SparkleMotion with MIT License | 4 votes |
/** * Build the third page Decors: a {@link PaperPlaneView } that draws a path within the page, and * two clouds the slide down as the page scrolls. */ private void buildDecorForPage2(SparkleViewPagerLayout parent, SparkleMotion sparkleMotion) { // Setup PaperPlaneView. final PaperPlaneView view = (PaperPlaneView) LayoutInflater.from(parent.getContext()) .inflate(R.layout.sparkle_page_2_plane, parent, false); Decor decor = new Decor.Builder(view) .setPage(Page.singlePage(1)) .behindViewPage() .slideOut() .build(); sparkleMotion.animate(new Animation(Page.singlePage(1)) { @Override public void onAnimate(View v, float offset, float offsetInPixel) { offset = Math.abs(offset); view.animate(offset); } }).on(decor); final int cloudMargin = getResources().getDimensionPixelOffset(R.dimen.icon_cloud_margin); final Drawable cloud = ContextCompat.getDrawable(this, R.drawable.cloud); // Setup small cloud. FrameLayout.LayoutParams lpSmallCloud = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lpSmallCloud.leftMargin = cloudMargin; lpSmallCloud.topMargin = cloudMargin; ImageView smallCloud = new ImageView(parent.getContext()); smallCloud.setLayoutParams(lpSmallCloud); smallCloud.setTranslationY(-cloud.getIntrinsicHeight() - lpSmallCloud.topMargin); smallCloud.setImageDrawable(cloud); // Setup large cloud. FrameLayout.LayoutParams lpBigCloud = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); lpBigCloud.gravity = Gravity.RIGHT; lpBigCloud.topMargin = (int) (cloud.getIntrinsicHeight() * 1.6f); ImageView bigCloud = new ImageView(parent.getContext()); bigCloud.setLayoutParams(lpBigCloud); bigCloud.setTranslationY(-cloud.getIntrinsicHeight() * 1.6f - lpBigCloud.topMargin); bigCloud.setScaleX(1.6f); bigCloud.setScaleY(1.6f); bigCloud.setImageDrawable(cloud); Page page = Page.singlePage(1); Decor cloudDecor1 = new Decor.Builder(smallCloud).setPage(page).slideOut().withLayer().build(); Decor cloudDecor2 = new Decor.Builder(bigCloud).setPage(page).slideOut().withLayer().build(); TranslationAnimation translationAnimation1 = new TranslationAnimation(page, 0, smallCloud.getTranslationY(), 0, 0, true); TranslationAnimation translationAnimation2 = new TranslationAnimation(page, 0, bigCloud.getTranslationY(), 0, 0, true); sparkleMotion.animate(translationAnimation1).on(cloudDecor1); sparkleMotion.animate(translationAnimation2).on(cloudDecor2); }