我有一個像下面這樣的相對佈局,當我將RelativeLayout
高度硬編碼爲25dp時,它沒有問題,如下圖所示。如何根據「相對佈局」中Android元素的總高度使垂直線可展開?
我要的是,當紅色水平線可以自動擴展高度時TextView
成爲多行,而不是硬編碼的高度。
這裏是我的代碼
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:id="@+id/line"
android:layout_width="3dp"
android:layout_height="match_parent"
android:background="@color/blue" />
<TextView
android:id="@+id/TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:layout_toEndOf="@+id/line"
android:layout_toRightOf="@+id/line"
android:text="TextView"
android:textColor="@color/black"
android:textSize="14sp" />
</RelativeLayout>
當我改變RelativeLayout
高度wrap_content
,垂直線變得不可見。
所以我的問題是,如何使垂直line
高度可以擴展取決於高度TextView
?
檢查這個https://stackoverflow.com/questions/15128652/how-to-add-vertical分頻到一個水平-的LinearLayout –