I'm using LinearLayout because it's the only way I can use layout_weight and I'm not familiar enough with aligning textviews evenly in RelativeLayout. (I'm new to android). I'm making a calendar app and can't seem to figure out how to get a textview below my 7 textviews. (The 7 textviews are the days of the week). They end up showing all on the same row.
How do I get the final textview below my 7 days? Please note I've searched this question on stackoverflow but I haven't found anything that made sense to me or worked.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="top" >
<TextView
android:id="@+id/day1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="@string/day1"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/day2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="@string/day2"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/day3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="@string/day3"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/day4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="@string/day4"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/day5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="@string/day5"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/day6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="@string/day6"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/day7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1"
android:text="@string/day7"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="a text string below"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
Simplified:
<LinearLayout android:orientation="vertical">
<LinearLayout android:orientation="horizontal" android:layout_weight="1">
<!-- TextView 1,2,3,4,5,6,7 here -->
</LinearLayout>
<TextView android:layout_weight="1"/><!-- (TextView 8) -->
</LinearLayout>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With