How I can multiline the expanded title of CollapsingToolbarLayout?

前端 未结 5 1385
暖寄归人
暖寄归人 2021-02-03 20:13

My problem is the next. I would use relatively large texts as CollapsingToolbarLayout title so I need to show it as multiline mode. When I try to change text appearance through

5条回答
  •  既然无缘
    2021-02-03 20:49

    With the release of new Material Design 1.2.0-alpha05 this feature is implemented as a native function.

    implement material library with version after(1.2.0-alpha05):

    implementation 'com.google.android.material:material:1.2.0-alpha05'
    

    Add this line to XML of Collapsing Toolbar Layout (this example I set 2 lines as max)

    app:maxLines="2"
    

    Alternatively you can set it programmatically

     collapsingtoolbar.setMaxLines(2);
    

提交回复
热议问题