Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

What do I do if my layout runs off the screen?

+5 votes
When I use the grid layout, my app gets cut off on the right side. The layout seems to be larger than the device screen. Has anyone else run into this problem?
asked Mar 13, 2015 in Spring 2015 by Lindsey Nicolaysen (100 points)

3 Answers

+4 votes
 
Best answer
I went back and played with an example, and for me the *key* fix was that *all three* of the LinearLayouts needed to have their "layout:width" set to "wrap_content" (and their layout:gravity set to "fill_horizontal").
answered Mar 16, 2015 by Forrest Stonedahl (100 points)
selected Apr 20, 2015 by Lindsey Nicolaysen
0 votes
This happened to me, and I think its from the layout width property of the grid layout (atleast that's what mine was). But its hard to know without seeing any of the properties or code. It could also be from some of the properties of cells in the right most column
answered Mar 15, 2015 by Trevor Warner (100 points)
0 votes
In the 3 Linear Layouts, change the width to 0dp (or leave it blank), this allows the grid layout to take control of the width and it should display properly.

Note: The GUI may not allow you to set that value, so you may have to edit the XML directly
answered Mar 15, 2015 by Daniel Shultz (100 points)
Hmm... I'm skeptical that the LinearLayouts should have the width set to 0dp.  The components inside the LinearLayouts should, because they also have the layout:weight set to 1, so the LinearLayout sizes them based on the weight of each widget, rather than the width.  I should take a look at your XML again, to see what you did.
...