【问题标题】:Button with 2 lines of text带有 2 行文本的按钮
【发布时间】:2019-11-20 11:16:03
【问题描述】:

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

android:maxLines="2"

没用

有什么建议吗?

【问题讨论】:

标签: android android-layout android-button material-components material-components-android


【解决方案1】:

使用类似的东西:

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

【讨论】:

    【解决方案2】:

    Android 普通的Button 小部件没有这样的功能。

    你必须使用android新库

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

    Here 是参考。

    @Gabriele Mariotti 已经定义了使用它的一种方式。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-16
      • 1970-01-01
      • 1970-01-01
      • 2021-03-11
      • 2013-10-06
      • 1970-01-01
      • 2017-09-10
      • 1970-01-01
      相关资源
      最近更新 更多