Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Android

Help with extra credit: Position four ImageViews so they always take up a quarter of the screen

I've been trying to solve this extra credit challenge in Build a Simple Android App > Creating the Screen Layout. It says: "See if you can position four ImageViews so that each one takes up one quarter of the screen no matter how you size it."

After some searching I tried accomplishing this by nesting a LinearLayout within the RelativeLayout and then using the layout_weight property, but I just couldn't get it to work.

Does anyone have any hints or suggestions on how to approach this challenge?

1 Answer

Don't use that RelativeLayout, instead, use a LinearLayout(horizontal) set the weightSum to 1 and inside of that LinearLayout add two LinearLayout(vertical) and in each one of those set the layout:height to "wrap_content",layout:width to "match_parent" and layout:weight to 0.5, i think that you can continue from here, but if you can't feel free to ask

Thanks, this worked for me!

sorry this is super old, but i cant get LinearLayout to stand on it's own without being a child of RelativeLayout. How can i get LinearLayout to stand on it's own?

also when you mention setting layout:height and width, do you mean the image views or the layouts themselves?