gpt4 book ai didi

android - 无法将按钮标签包装在 Material Button Toggle Group 内

转载 作者:行者123 更新时间:2023-12-05 03:33:52 26 4
gpt4 key购买 nike

我在 MaterialButtonToggleGroup 中有三个按钮。问题是所有的标签都被切断了,没有包裹

Screenshot of the layout

 <com.google.android.material.button.MaterialButtonToggleGroup
android:id="@+id/toggle_pomo_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="@dimen/margin_medium"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/pomo_card"
app:singleSelection="true">

<Button
android:id="@+id/bt_pomo"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/class_time" />

<Button
android:id="@+id/bt_short_break"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/short_break" />

<Button
android:id="@+id/bt_long_break"
style="@style/Widget.MaterialComponents.Button.OutlinedButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/long_break" />

</com.google.android.material.button.MaterialButtonToggleGroup>

我搜索了很多,但找不到任何合适的解决方案。任何帮助将非常感激。谢谢。

最佳答案

您不能将它们包装在一行中,因为 MaterialButtonToggleGroup View 的测量宽度被声明为有限的,因此它决定在最后将它们椭圆化。您可以验证是否使用了更宽的屏幕或横向模式,如果文本仍在允许的宽度范围内,文本将换行。

移除按钮的水平填充 android:paddingHorizo​​ntal="0dp" 会腾出一点空间。

但是您可以通过编程方式在两行中完成;因为 android:maxLength 属性不适用于 here 描述的错误:

val bt_pomo= findViewById<Button>(R.id.bt_pomo)
bt_pomo.maxLines = 2

对其他两个按钮重复同样的操作

关于android - 无法将按钮标签包装在 Material Button Toggle Group 内,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70269540/

26 4 0