I have an imageView
with layout_width="match_parent"
.
On my adapter's getView()
, I'd like to get the actual width of this imageView
but don't know how.
I tried using imageView.getWidth()
, but this returns 0.
The view is not attached to its parent group in getView()
, so it hasn't been measured, hence the zero width. The only way I can think of is to do a parent.getWidth()
which returns the width of the ViewGroup. This will only work when your view is not going to be placed next to another view in parent. This is usually the case for ListView
, so may work for your case.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With