Having a TextView , its width should not exceed 1/3 of its parent width. If its width is less than 1/3 of the parent, then it should have the wrap_content behavior. His horizontal sibling will always be by his side.
Tried to follow, it always has a hard cut 1/3 and 2/3, therefore, if text1 has less space than 1/3, then two TextView will not start next to it.
change the value of LinearLayout to RelativeLayout , then android:layout_weight="n" does not work
in principle, you need to determine the width of wrap_content , and maxWidth will not exceed 1/3.
any suggestion?
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:weightSum="3"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:singleLine="true" android:ellipsize="end" /> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_width="0dp" android:singleLine="true" android:ellipsize="end" android:layout_weight="2" /> </LinearLayout>
android textview android-layout-weight
lannyf
source share