Skip to content

Instantly share code, notes, and snippets.

@edwardinubuntu
Last active August 29, 2015 14:17
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 edwardinubuntu/b52db21f922cda8f3160 to your computer and use it in GitHub Desktop.
Save edwardinubuntu/b52db21f922cda8f3160 to your computer and use it in GitHub Desktop.
Set image view height equals to width.
final ImageView dreamImageView = (ImageView)rootView.findViewById(R.id.dream_image_view);
DisplayMetrics displayMetrics = getContext().getResources().getDisplayMetrics();
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)dreamImageView.getLayoutParams();
params.height = displayMetrics.widthPixels;
dreamImageView.setLayoutParams(params);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment