android - What's a simple way to make a view's layout_width="match_parent" and make the height equal to its width? -



android - What's a simple way to make a view's layout_width="match_parent" and make the height equal to its width? -

i view styled similar album fine art in rdio app (img)

i don't know how should going this. want load bitmap view, if affects solution @ all.

in case (where command has total width of device) can utilize getwindowmanager().getdefaultdisplay().getwidth(); width , manually set height.

if you're not using total display width you'll need override onmeasure in view class , set height match width in there, perhaps this:

@override protected void onmeasure( int widthmeasurespec, int heightmeasurespec ) { viewwidth = measurespec.getsize( widthmeasurespec ); viewheight = measurespec.getsize( heightmeasurespec ); if(viewwidth != 0) viewheight = viewwidth; setmeasureddimension( viewwidth, viewheight ); }

android android-layout

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

intellij idea - Update external libraries with intelij and java -

javascript - send data from a new window to previous window in php -