Example usage for android.widget FrameLayout getHeight

List of usage examples for android.widget FrameLayout getHeight

Introduction

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

Prototype

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

Source Link

Document

Return the height of your view.

Usage

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;/*w ww  .  j a va2 s  .  c  o  m*/
}

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

/**
 * Set the player view size with givent width and height
 * //from   ww  w.java2s  . c  o  m
 * @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);
}