我的設計包含一個按鈕組,其中的選擇,例如:
。
我想實作這個按鈕被平均拉伸到Button Toggle Group的寬度,就像這里的照片:
。
我試著在Button Toggle Group里面添加ConstraintLayout,但是沒有成功,我已經沒有任何想法了。請幫助我,以下是代碼:
<com.google.android.material.button.MaterialButtonToggleGroup
android:id="@ id/button_group"/span>
android:layout_width="380dp"/span>
android:layout_height="wrap_content"/span>
android:layout_marginStart="15dp"/span>
android:layout_marginEnd="15dp"。
android:gravity="center">
<按鈕
android:id="@ id/button_one"/span>
style="?attr/materialButtonOutlinedStyle"。
android:layout_width="wrap_content"
android:layout_height="wrap_content"/span>
android:text="Bachelor" />
<按鈕
android:id="@ id/button_center"/span>
style="?attr/materialButtonOutlinedStyle"。
android:layout_width="wrap_content"
android:layout_height="wrap_content"/span>
android:text="Master" />
<按鈕
android:id="@ id/button_three"/span>
style="?attr/materialButtonOutlinedStyle"。
android:layout_width="wrap_content"
android:layout_height="wrap_content"/span>
android:text="Doctoral" />
</com.google.android.material.button.MaterialButtonToggleGroup>
uj5u.com熱心網友回復:
你可以使用所有按鈕上的android:layout_weight屬性來解決這個問題,寬度為0dp來應用權重:
<Button
....
android:layout_width="0dp"/span>
android:layout_weight="1" />
對其余的按鈕采用同樣的方法。
之前:
。后:
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/313064.html
標籤:
上一篇:重新審核網格布局的動態高度


