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 Android Activity Lifecycle The Project Adding the Menu

Daniel Prowse
Daniel Prowse
7,941 Points

Layout is different when app runs

The golf score card works its just the layout seems to be getting squished together, however in the editor it is not? https://snag.gy/rYXnFj.jpg image will explain better.

Thanks in advance :)

4 Answers

Daniel Prowse
Daniel Prowse
7,941 Points

Fixed it! thanks for your help, however after i checked the ListView in activity_main.xml i changed the ListView's android layout properties from wrap content to match_parent android:layout_width="match_parent" android:layout_height="match_parent"

all fits the screen fine now with no errors anywhere :)

Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,795 Points

Hi Daniel Prowse

The squishing may be caused by not setting the android:gravity attribute. Have you used android:layout_weight attribute on your xml layout file?. Kindly paste it here, please. Alternatively, compare with my below xml layout file

I have also seen on the image shared that hole No. 10 has slightly shifted to the Right and this is because 10 has 2 digits as opposed from numbers one to nine which have a single

Daniel Prowse
Daniel Prowse
7,941 Points

compared mine to your xml file and it is the same. Experimented with the gravity and layout_gravity attributes but still no success. Mind boggling this one.

edit: was thinking maybe its something to do with the ListView that the list_item gets put into

Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,795 Points

Please see my xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:orientation="horizontal"
    android:layout_height="match_parent">

    <TextView
        android:id="@+id/holeLabel"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="3"
        android:textSize="24sp"
       tools:text="Hole 1:" />


    <TextView
        android:id="@+id/strokeCount"
        android:layout_width="0dp"
        android:textSize="24sp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        tools:text="0" />

    <Button
        android:id="@+id/removeStrokeButton"
        android:layout_width="0dp"
        android:textSize="24sp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="-" />

    <Button
        android:id="@+id/addStrokeButton"
        android:layout_width="0dp"
        android:textSize="24sp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="+" />
</LinearLayout>