How to make TextView's to be same width in TableRow even text in one of the views is much bigger?
<TableRow
android:layout_weight="1"
android:gravity="center"
>
<TextView
android:layout_width="match_parent"
android:text="Temperature"
android:gravity="center"
></TextView>
<TextView
android:layout_width="match_parent"
android:text="Temperatureccccccccccccccccccccccccc"
android:gravity="center"
></TextView>
</TableRow>

You can set the width of your
TextViewto some fixed value. If you don't want the additional text to go to next line limit the number of lines usingmaxLinesattribute.NOTE: Be careful when you use fixed-width. The text size can change based on device settings irrespective of the text size you specify, so the text may not be visible completely if your text view has fixed size, and user's device settings use a large text size.
Sample Output:
Without
maxLinesattributeWith
maxLinesattributeIf you want to take the space equally use
layout_weightproperty. It divides available space equally among two text views. Make sure to set thelayout_widthto 0dp.Sample Output: