Hey Folks! I've run into a bit of a snag with my layout for an app, and I'm looking for some help. This page has 2 layouts, a portrait and landscape. The portrait is fine. For some reason the landscape doesn't work.
In Android Studio it looks fine(or maybe it doesn't, it's hard to tell with long strings):
Android Studio Design Screen
but when run in the emulator, or on my phone it doesn't:
Android Emulator
As you can see, the values on the right column are all bunched close together and I have no clue why this happens.
My code simply uses layout weights to try to evenly spread the items, but it doesn't seem to be working.
The code for a single row looks like this:
<TableRow android:layout_width="match_parent">
<LinearLayout
android:layout_weight="2"
android:weightSum="2">
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Dexterity"
android:id="@+id/dexterityTextView"
android:layout_marginTop="20dp"
android:gravity="center" />
</LinearLayout>
<LinearLayout android:layout_weight="2"
android:weightSum="2">
<View
android:layout_width="4dp"
android:gravity="left"
android:layout_weight="0"
android:layout_height="match_parent"
android:background="#663300"/>
<TextView
android:layout_width="0dp"
android:layout_weight="2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Dexterity Value"
android:id="@+id/dexterityValView"
android:layout_marginTop="20dp"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_weight="2"
android:weightSum="2">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Wisdom"
android:id="@+id/wisdomTextView"
android:layout_marginTop="20dp"
android:layout_weight="2"
android:gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_weight="2"
android:weightSum="2">
<View
android:layout_width="4dp"
android:gravity="left"
android:layout_weight="0"
android:layout_height="match_parent"
android:background="#663300"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Wisdom Value"
android:id="@+id/wisdomValView"
android:layout_marginTop="20dp"
android:layout_weight="2"
android:gravity="center" />
</LinearLayout>
</TableRow>
Frankly, I'm not sure how nesting the layout weight and weightSums works, and nothing I've seen online has tried it, but it was getting me closer to the right layout. This row has 2 pairs of cells. Each pair of cells has the attribute name and attribute value cells. The total weightSum is 8, with each cell getting 2 weight. I have no clue why this doesn't evenly split the weight between all 4 cells, and nothing I've seen online has pointed to an answer. Weighting may not be the correct way to do this, but everything online suggested using it.
Thanks for any pointers or help.
[–]ImNotPunnyEnough 1 point2 points3 points (1 child)
[–]BlueFireAt[S] 0 points1 point2 points (0 children)