Skip to content

Instantly share code, notes, and snippets.

@ayltai
Created February 12, 2017 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayltai/6d3f84ffe8bf81c92abf3505e4e61254 to your computer and use it in GitHub Desktop.
Save ayltai/6d3f84ffe8bf81c92abf3505e4e61254 to your computer and use it in GitHub Desktop.
DisplayMetrics metrics = new DisplayMetrics();
((WindowManager)adContainerView.getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay().getMetrics(metrics);
ViewGroup.LayoutParams params = imageView.getLayoutParams();
params.width = metrics.widthPixels;
params.height = (int)(metrics.widthPixels / 1.91f + 0.5f);
imageView.setLayoutParams(params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment