Example usage for android.widget FrameLayout getWidth

List of usage examples for android.widget FrameLayout getWidth

Introduction

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

Prototype

@ViewDebug.ExportedProperty(category = "layout")
public final int getWidth() 

Source Link

Document

Return the width of your view.

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);

    /*//from w  ww  .  j a v  a 2  s  . co 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)));
    }

}

From source file:com.ezartech.ezar.videooverlay.ezAR.java

private Size getDefaultWebViewSize() {
    FrameLayout cvcParent = (FrameLayout) cordovaViewContainer.getParent();
    Size sz = new Size(cvcParent.getWidth(), cvcParent.getHeight());
    return sz;/*from  w  w w.jav a2  s  .com*/
}

From source file:br.ufrgs.ufrgsmapas.libs.SearchBox.java

private void revealFrom(float x, float y, Activity a, SearchBox s) {
    FrameLayout layout = (FrameLayout) a.getWindow().getDecorView().findViewById(android.R.id.content);
    RelativeLayout root = (RelativeLayout) s.findViewById(R.id.search_root);
    Resources r = getResources();
    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96, r.getDisplayMetrics());
    int cx = layout.getLeft() + layout.getRight();
    int cy = layout.getTop();

    int finalRadius = (int) Math.max(layout.getWidth(), px);

    SupportAnimator animator = ViewAnimationUtils.createCircularReveal(root, cx, cy, 0, finalRadius);
    animator.setInterpolator(new AccelerateDecelerateInterpolator());
    animator.setDuration(500);/* w w w . ja  v  a 2  s. c  o  m*/
    animator.addListener(new SupportAnimator.AnimatorListener() {

        @Override
        public void onAnimationCancel() {

        }

        @Override
        public void onAnimationEnd() {
            toggleSearch();
        }

        @Override
        public void onAnimationRepeat() {

        }

        @Override
        public void onAnimationStart() {

        }

    });
    animator.start();
}

From source file:br.ufrgs.ufrgsmapas.libs.SearchBox.java

/***
 * Hide the searchbox using the circle animation. Can be called regardless of result list length
 * @param activity Activity//from w  ww.  jav a  2 s  .co m
 */
public void hideCircularly(Activity activity) {
    Display display = activity.getWindowManager().getDefaultDisplay();
    Point size = new Point();
    final FrameLayout layout = (FrameLayout) activity.getWindow().getDecorView()
            .findViewById(android.R.id.content);
    RelativeLayout root = (RelativeLayout) findViewById(R.id.search_root);
    display.getSize(size);
    Resources r = getResources();
    float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 96, r.getDisplayMetrics());
    int cx = layout.getLeft() + layout.getRight();
    int cy = layout.getTop();
    int finalRadius = (int) Math.max(layout.getWidth() * 1.5, px);

    SupportAnimator animator = ViewAnimationUtils.createCircularReveal(root, cx, cy, 0, finalRadius);
    animator.setInterpolator(new ReverseInterpolator());
    animator.setDuration(500);
    animator.start();
    animator.addListener(new SupportAnimator.AnimatorListener() {

        @Override
        public void onAnimationStart() {

        }

        @Override
        public void onAnimationEnd() {
            setVisibility(View.GONE);
        }

        @Override
        public void onAnimationCancel() {

        }

        @Override
        public void onAnimationRepeat() {

        }

    });
}

From source file:com.hotstar.player.adplayer.player.PlayerFragment.java

/**
 * Set the player view size with givent width and height
 * /*from   w  ww  .j  a  va2s .  c om*/
 * @param movieWidth
 *            the width of the player view to be set to
 * @param movieHeight
 *            the height of the player view to be set to
 */
private void setPlayerViewSize(long movieWidth, long movieHeight) {
    if (mediaPlayer == null || mediaPlayer.getView() == null) {
        AdVideoApplication.logger.w(LOG_TAG + "#setPlayerViewSize", "Unable to find player view.");
        return;
    }

    AdVideoApplication.logger.i(LOG_TAG + "#setPlayerViewSize",
            "Original movie size: " + movieWidth + "x" + movieHeight);

    FrameLayout layout = (FrameLayout) playerFragmentView.findViewById(R.id.playerFrame);
    int layoutWidth = layout.getWidth();
    int layoutHeight = layout.getHeight();
    float screenAspectRatio = (float) layoutWidth / layoutHeight;

    if (movieWidth == 0 || movieHeight == 0) {
        // If movie size is not available, fill the screen.
        movieWidth = layoutWidth;
        movieHeight = layoutHeight;
    }

    float movieAspectRatio = (float) movieWidth / movieHeight;
    int width, height;

    if (movieAspectRatio <= screenAspectRatio) {
        // Resize to fill height.
        width = (int) (layoutHeight * movieAspectRatio);
        height = layoutHeight;
    } else {
        // Resize to fill width.
        width = layoutWidth;
        height = (int) (layoutWidth * (1 / movieAspectRatio));
    }

    AdVideoApplication.logger.i(LOG_TAG + "#setPlayerViewSize",
            "Movie width x height: " + movieWidth + "x" + movieHeight);
    AdVideoApplication.logger.i(LOG_TAG + "#setPlayerViewSize",
            "Setting player view size to: " + width + "x" + height);
    mediaPlayer.getView().setLayoutParams(
            new FrameLayout.LayoutParams(width, height, Gravity.CENTER_VERTICAL | Gravity.CENTER_HORIZONTAL));
    RelativeLayout overlayAdLayout = (RelativeLayout) playerFragmentView.findViewById(R.id.OverlayAdLayout);
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(width, height);
    layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, 1);
    layoutParams.addRule(RelativeLayout.ABOVE, controlBar.getView().getId());
    overlayAdLayout.setLayoutParams(layoutParams);
}