layout - Android set ImageView's width as a ratio of another element (given the id) -


i have imageview:

<imageview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/pbc"     android:layout_below="@id/ryc"/> 

is possible set it's width percentage of of element of id "@id/ryc" i've done in android:layout_below ?if so, how?

thanks

you need set width in activity, following code (just change yourpercentage percentage want)(i have added id imageview, can change it):

xml:

<imageview     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:src="@drawable/pbc"     android:id="@+id/pbcimageview"     android:layout_below="@id/ryc"/> 

activity:

float perc = yourpercentage / 100; imageview imgview = (imageview) findviewbyid(r.id.ryc); imageview pbcimageview = (imageview) findviewbyid(r.id.pbcimageview); pbcimageview.setwidth(imgview.getwidth() * perc) 

hope helps!


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -