Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialL YH
Courses Plus Student 943 Pointsandroid:adjustViewBounds="true" not working
Hi, at the android tutorial Implementing Designs for Android->Customizing a GridView for Friends->Adding Images to the GridView the android:adjustViewBounds="true" is not working. I try to download the source file and pull into Eclipse but the results is still the same.
1 Answer
Unsubscribed User
12,721 PointsI think the issue is because of the drawable resource avatar_empty.png which are included in the Ribbit Assets zip file downloaded earlier. All resources are suitably re-sized as per the different screen sizes - mdpi, hdpi, xhdpi and so on. However, the 'adjustViewBounds' attribute requires images to be of a certain size or more to work (204 px or above in height ~ xxhdpi). This is because the 'adjustViewBounds' will not increase the size of the ImageView beyond the natural dimensions of the drawable. It will only shrink the view to maintain aspect ratio.
Therefore the solution is : Replace the avatar_empty.png in each of the drawable folders less than xxhdpi standards with the avatar_empty.png in the drawable-xxhdpi folder.
Gilad Solter
2,986 Pointsworks great! Thanks!
So, what's the downside here?
Jeremy Jiang
3,075 PointsPerfect! Thanks~
Adel Fatkhutdinov
1,697 PointsThanx a lot!!!
Unsubscribed User
12,721 PointsUnsubscribed User
12,721 PointsUpdate: Posted the answer below, please see if it helps
Not working for me either.
I am using a Genymotion Nexus 4- 4.2.2 - API 17- 768x1280 emulator.
The result is the same stretched image for user Avatar - with or without the adjustImageBounds parameter in the imageView.