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 trial
Chase Erickson
41 PointsSupporting Different Devices
Hey all, I'm having a crazy issue that I'm guessing is caused by me forgetting to put a certain line of code somewhere. I'm having trouble catching it in LogCat, so I'm going to try my best to explain it. I'm creating a very basic app with only one activity, and displayed on the interface are several ImageButtons that are linked to webpages through simple intents. I programmed all the ImageButtons properly and there are no errors. Here is what's going on:
In layout-main, I arranged all the ImageButtons the way I wanted them to appear in Graphical Layout using Relative Layout, but when I plugged in my Galaxy 4 to test the application, the ImageButtons were scaled weirdly and out of place. Then I went through the grueling work of scaling and placing the ImageButtons even more weirdly in the xml file and continuously testing it until it finally looked right on my Galaxy 4 (even though it looked ridiculous in Graphical Layout). Additionally, it ONLY looks good on my Galaxy 4; when I test it on my Galaxy 2 or Galaxy Tab 3 the ImageButtons are out of place and scaled oddly. Keep in mind that despite this, it still LOADS properly on every device I test it on (meaning it at least appears without crashing), and works PERFECTLY on my Galaxy 4.
Next, I did research and discovered the information on the developer site about designing for multiple screens, so here's what I did:
Scaled all my drawable PNG files in Photoshop in accordance to the four different size ratios recommended on the developer site, then placed them appropriately in the four different drawable folders (ldpi, mdpi, hdpi, xhdpi).
Created the following copies of the layout folder: layout-land, layout-small, layout-small-land, layout-large, layout-large-land, layout-xlarge, layout-xlarge-land.
Opened each layout folder's xml and arranged all the ImageButtons to appear the way I would want them to in the app, including landscape modes.
Entered the following into the manifest: <supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:xlargeScreens="true" android:anyDensity="true" />
I "save all" and there are no errors so I hit Run and the app collapses immediately on my Galaxy 4. It launches with a black screen, and then says "Unfortunately, (the app) has stopped." Once again, it worked perfectly on my Galaxy 4 before doing those four steps listed above, so I figure I must have left something out somewhere. Any information or ideas will be a big help, and I will try to capture some LogCat info as well. I appreciate your time.
1 Answer
Ben Jakuben
Treehouse TeacherAndroid layouts are hard! I plan on covering them in detail before too long, and I start in my next project, which is due in about 2 weeks.
Sounds like you're on the right path. Can you paste in the XML of the layout file giving you trouble? It might also help if you take a screenshot of your res directory expanded to show everything.
If that's not enough information for us to help then you can zip up your project and email it to us at help@teamtreehouse.com.