I have the following setup:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:subtitleTextAppearance="@style/TitleTextStyle"
app:theme="@style/ActionBarStyle.Light"/>
and
<style name="TitleTextStyle">
<item name="android:maxLines">2</item>
<item name="android:textAllCaps">false</item>
</style>
and
getSupportActionBar().setSubtitle( targetString );
the @textAllCaps
is applied, but @maxLines
is ignored (I tried also `@minLines).
How to enable multiline text in subtitle?
TIA
UPDATE:
I added the code into the onStart
:
@Override
public void onStart() {
super.onStart();
try{
Field field = Toolbar.class.getDeclaredField( "mSubtitleTextView" );
field.setAccessible( true );
subtitleTextView = (TextView)field.get( toolbar );
subtitleTextView.setSingleLine( false );
subtitleTextView.setMaxLines( 2 );
subtitleTextView.setEllipsize( TruncateAt.END );
}catch( Exception e ) {
Logg.e( this, "", e );
}
}
the problem is now, that the ellipsize values are applied, but setMaxLines()
call is ignored...
UPD2:
setSingleLine( false )
did the trick.