Skip to content

Instantly share code, notes, and snippets.

@mikedg1
Last active November 30, 2020 19:34
Show Gist options
  • Select an option

  • Save mikedg1/11478522 to your computer and use it in GitHub Desktop.

Select an option

Save mikedg1/11478522 to your computer and use it in GitHub Desktop.
/**
* Ask all children to measure themselves and compute the measurement of this
* layout based on the children.
*/
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
mPortrait = (ViewGroup) findViewById(R.id.portrait);
if (mPortrait != null) {
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) mPortrait.getLayoutParams();
int desiredWidth = MeasureSpec.getSize(widthMeasureSpec);
int desiredHeight = desiredWidth / 16 * 9;
params.height = desiredHeight;
mPortrait.setLayoutParams(params);
}
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
// measureChild(mWatchView,widthMeasureSpec, heightMeasureSpec);
// measureChild(mWatchView, MeasureSpec.makeMeasureSpec(
// currentPlayer.width(), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(
// currentPlayer.height(), MeasureSpec.EXACTLY));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment