如何在LinearLayout中在約束佈局中平均佔用空間?
例如,如果下面的佈局是用約束書寫的,會怎樣呢?如何模仿具有約束佈局的加權LinearLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="A"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="B"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="C"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
<TextView
android:id="D"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1" />
</LinearLayout>
在約束佈局,我可以設置A
和D
到邊緣,A←B→D
帶33個偏壓和A←C→D
用66個偏壓種具有各元件之間具有相等的空間。
該解決方案雖然並沒有真正擴展。
有沒有一種合適的方法在約束佈局中做到這一點?
你真的需要直接在ConstraintLayout的項目,或者你可以把他們在的LinearLayout,並把LinearLayout中進ConstraintLayout – lionscribe
@lionscribe ConstraintLayout在這裏除了別的以外,還可以製作平面設計和幫助表演。因此,我正在尋找一種平坦的方式來完成此任務,而無需其他任何嵌套佈局。 – oldergod
在https://developer.android.com/training/constraint-layout/index.html有這方面的新文檔 –