Actual layout does not look like the layout in the book


#1

The actual layout on my machine does not look like Figure 1.11. The widgets within the root LinearLayout overlap each other:

The content of activity_quiz.xml is exactly as printed in Listing 1.2.


#2

Do you have a second linear layout within the root Linear Layout? The second (child) linear layout contains both the true and false buttons. The Root linear layout holds the TextView.


#3

Thank you for pointing me in the right direction. I forgot to change the root layout from RelativeLayout to LinearLayout. Now the layout looks as expected. Thanks a lot!


#4

My layout items do not overlap, but they are all left-justified instead of centered in the display as demonstrated in the book. I also do not have any errors in the layout file…I followed the code explicitly. Is there any way to get the buttons centered within the LinearLayout where they reside?


#5

Having an issue too but didn’t think it warranted a new thread. The text in the two buttons is shifted right.

docs.google.com/file/d/0B13QW0P … sp=sharing

Everything seems to be the default (centered) but the text is kinda large.


#6

Double check the XML attributes on your buttons. It may be that you’ve set your layout_width to a different value from that specified in the book.


#7

Shouldn’t there be a line included as follows:

    android:layout_gravity="center

This would be center the buttons.


#8

[quote=“mbinna”]The actual layout on my machine does not look like Figure 1.11. The widgets within the root LinearLayout overlap each other:

The content of activity_quiz.xml is exactly as printed in Listing 1.2.[/quote]

Can you share your xml file?


#9

Sorry I forgot to report back in. I called it a night and when I restarted the layout looked correct. Mush have just been a glitch.


#10

[quote=“DennisSmith”]Shouldn’t there be a line included as follows:

    android:layout_gravity="center

This would be center the buttons.[/quote]

When I took your advice and added the android:layout_gravity=“center” line, the layout worked perfectly. Both the horizontal and vertical arrangement were as shown in the book.