带有 2 行文本的按钮

Button with 2 lines of text

我想要一个包含 2 行文本的按钮,如果文本超过 2 行且大小为 maxWidth,则文本应适合按钮边框。

android:maxLines="2"

不起作用

有什么建议吗?

使用类似的东西:

<com.google.android.material.button.MaterialButton
    android:layout_width="150dp"
    android:layout_height="wrap_content"
    android:maxLines="2"
    ../>

Android 正常 Button 小部件没有这样的功能。

您必须使用 android 新库

implementation 'com.google.android.material:material:1.0.0-beta01'

Here为参考。

@ 已经定义了一种使用方法。