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 trialDaniel Prowse
7,941 PointsLayout 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
7,941 PointsFixed 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
UX Design Techdegree Graduate 22,796 PointsThe 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
7,941 Pointscompared 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
UX Design Techdegree Graduate 22,796 PointsPlease 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>
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 PointsDaniel Prowse awesome, I am glad you managed to figure it out