Example usage for android.widget FrameLayout setTranslationX

List of usage examples for android.widget FrameLayout setTranslationX

Introduction

In this page you can find the example usage for android.widget FrameLayout setTranslationX.

Prototype

public void setTranslationX(float translationX) 

Source Link

Document

Sets the horizontal location of this view relative to its #getLeft() left position.

Usage

From source file:com.sociablue.nanodegree_p1.MovieDetailPagerFragment.java

private void horizontalParallax(int position, float positionOffsetPixels) {

    int id = mMovieList.get(position).getId();
    View currentPage = mPager.findViewWithTag(id);

    FrameLayout imgContainer = (FrameLayout) currentPage.findViewById(R.id.details_img_container);
    imgContainer.setTranslationX(positionOffsetPixels * 0.5f);

    /*/* www. j a va  2  s  .  c o  m*/
     * Modify the X translation of the view to the right of the current view by half the distance scrolled.
     * The leftmost view is always the current view regardless of the direction and amount of image visible.
     */
    if (position < mMovieList.size() - 1) {
        View rightPage = mPager.findViewWithTag(mMovieList.get(position + 1).getId());
        FrameLayout rightImgContainer = (FrameLayout) rightPage.findViewById(R.id.details_img_container);
        rightImgContainer.setTranslationX(-(((rightImgContainer.getWidth() - positionOffsetPixels) * 0.5f)));
    }

}