I'm messing around with Android Studio documents about layout_weight and I'm trying to get use to it. But something weird happens, I assume that if I give some elements value and, The rest will be calculated and distributed equally to which elements have layout_weight specified. Somehow the result make me confuse as There was lots of space left but the TextView decided to get super small and super long.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000000"
android:orientation="horizontal" >
<ImageView
android:layout_width="56dp"
android:layout_height="56dp"
android:scaleType="centerCrop"
android:src="@drawable/ocean" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pebble Beach"
android:background="#FF0"
android:textAppearance="?android:textAppearanceMedium" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="California"
android:background="#FF0"
android:textAppearance="?android:textAppearanceSmall" />
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="10 miles away"
android:background="#FF0"
android:textAppearance="?android:textAppearanceSmall" />
</LinearLayout>
question from:
https://stackoverflow.com/questions/66050880/layout-weight-isnt-distributing-equally-when-there-is-lot-of-space-left 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…