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 trialNicolas Blaisdell
19,157 PointsNeed help with layout on Golf Scorecard app
I've finished the Android Lifecycle course and the entire app is working no problems. The only thing that's bothering me is that the layout is incorrect on the list, and I can't seem to figure out why.
Even though I'm using layout_weight, and weightSum correctly (to my knowledge) and I've set the width of all the views to 0dp and it looks correct in my preview window, when I actually run the app, all of the views squeeze to the left of my screen instead of spreading apart.
Here is my xml for my list_item:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:weightSum="7" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent">
<TextView
android:layout_width="0dp"
android:layout_weight="3"
android:layout_height="wrap_content"
tools:text="Hole 1:"
android:textSize="24sp"
android:id="@+id/txtHoleLabel"/>
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
tools:text="0"
android:textSize="24sp"
android:id="@+id/txtStrokeCount"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="-"
android:textSize="24sp"
android:id="@+id/btnRemoveStroke"/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="+"
android:textSize="24sp"
android:id="@+id/btnAddStroke"/>
</LinearLayout>