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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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 aparent.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 forListView, so may work for your case.