Santhosh Yedidi Santhosh Yedidi - 1 year ago 365
Android Question

Android collapsing toolbar: How to resize the text, so that it shows full text than partially

I am using CollapsingToolbarLayout:

I am using the following code to show the title:

collapsingToolbar = (CollapsingToolbarLayout) findViewById(;
collapsingToolbar.setTitle("Udupi Sri krishna Temple");

The text is shown as below. It shows only partial and shows .. at the end. Is there a way to control the size so that it shows full text.

enter image description here

Answer Source

First define your text styles in styles.xml

<style name="TextAppearance.MyApp.Title.Collapsed" parent="android:TextAppearance">
    <item name="android:textColor">@android:color/white</item>
    <item name="android:textSize">11sp</item>

<style name="TextAppearance.MyApp.Title.Expanded" parent="android:TextAppearance">
    <item name="android:textColor">@android:color/white</item>
    <item name="android:textSize">14sp</item>

Note that the values are just examples; you need to change them to fit your app. Also, you may want a different TextAppearance style as a parent.

Then in XML :



in code:


EDIT: In the comments there is a discussion about multi-line text. CollapsingToolbarLayout does not support multi-line text. Please ignore my suggestion to use setCustomView() on the toolbar. According to docs:

Do not manually add views to the Toolbar at run time. We will add a 'dummy view' to the Toolbar which allows us to work out the available space for the title. This can interfere with any views which you add.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download