Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Material Design Collapsing Toolbar Layout title truncation

I am currently having an issue with the collapsing toolbar layout title. Currently mine automatically gets truncated even through android:ellipsize="end" and android:fitsSystemWindows has not been used. I have quite a few long titles but I am unable to get the titles to be displayed fully with android truncating them with "..." as per the screenshot: Truncated Image

I would be most grateful if someone could please help me on this matter. I am unsure if there is a way to have the title double line instead of single line whether that would help Cheers

ly_13_tachycardiapalpitations.xml:

tools:context=".HomeActivity">

<android.support.design.widget.AppBarLayout
    android:id="@+id/ly_13_tachycardiapalpitations.appbar"
    android:layout_width="match_parent"
    android:layout_height="300dp"

    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">


    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/ly_13_tachycardiapalpitations.collapsing"
        android:layout_width="match_parent"
        android:layout_height="match_parent"

        app:contentScrim="?attr/colorPrimary"

        app:expandedTitleMarginStart="0dp"

        app:layout_scrollFlags="scroll|exitUntilCollapsed">

        <ImageView
            android:id="@+id/ly_13_tachycardiapalpitations.imageview.placeholder"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            android:scaleType="centerCrop"
            android:src="@drawable/ly_11_lowurineoutputcatheterisedpatient_picture2"
            app:layout_collapseMode="parallax"
            app:layout_collapseParallaxMultiplier="0.7"/>

        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            app:layout_collapseMode="pin"
            android:minHeight="?attr/actionBarSize"

            app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
        <!--layout of pin mode is the one just above-->

    </android.support.design.widget.CollapsingToolbarLayout>

</android.support.design.widget.AppBarLayout>




<android.support.v4.widget.NestedScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:scrollbars="none"
    app:behavior_overlapTop="5dp"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"

    >
    <RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="vertical"
        >

        <android.support.v7.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="8dp"
            app:cardElevation="8dp"
            app:contentPadding="16dp"
            android:id="@+id/Cardview1"
            >
            <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"

                tools:context=".klass11LowUrineOutputCatheterisedPatient">

                <!--Title-->

                <!--Initial Assessment-->
                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Initial Assessment"
                    android:textSize="22dp"
                    android:padding="8dp"
                    android:textStyle="bold"
                    android:fontFamily="sans-serif-light"
                    android:gravity="left"
                    android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="14dp"
                    android:padding="8dp"
                    android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title"
                    android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_body" />



                <!--Examination-->
                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Examination"

                    android:fontFamily="sans-serif-light"
                    android:gravity="center"
                    android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_body"
                    android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_examination_title2" />

                <View
                    android:layout_width="match_parent"
                    android:layout_height="1dp"
                    android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title"
                    android:background="#ddd" />

                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_examination_title2"
                    android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_examination_body2" />



            </RelativeLayout>
        </android.support.v7.widget.CardView>
        <android.support.v7.widget.CardView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="8dp"
            app:cardElevation="8dp"
            app:contentPadding="16dp"
            android:id="@+id/Cardview2"
            android:layout_below="@+id/Cardview1"
            >
            <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                android:layout_width="match_parent"
                android:layout_height="match_parent"

                tools:context=".klass11LowUrineOutputCatheterisedPatient">

                <!--Title-->
                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="ATSP Re: Decreased GCS2"

                    android:fontFamily="sans-serif-light"
                    android:gravity="center"
                    android:textStyle="bold"
                    android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_topic_title2" />

                <!--Initial Assessment-->
                <TextView
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:text="Initial Assessment"

                    android:fontFamily="sans-serif-light"
                    android:gravity="center"
                    android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_topic_title2"
                    android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title2" />
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_below="@id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_title2"
                    android:id="@+id/ly_11_lowurineoutputcatheterisedpatient_initial_assessment_body2" />




            </RelativeLayout>
        </android.support.v7.widget.CardView>

    </RelativeLayout>
</android.support.v4.widget.NestedScrollView>

<!--<android.support.design.widget.FloatingActionButton-->
    <!--android:layout_width="wrap_content"-->
    <!--android:layout_height="wrap_content"-->
    <!--android:layout_gravity="bottom|end"-->
    <!--android:layout_marginBottom="@dimen/activity_vertical_margin"-->
    <!--android:layout_marginEnd="@dimen/activity_horizontal_margin"-->
    <!--android:layout_marginRight="@dimen/activity_horizontal_margin"-->
    <!--android:src="@mipmap/ic_launcher">-->

<!--</android.support.design.widget.FloatingActionButton>-->

Activity: klass13Tachycardiapalpitations.java

package com.heemobileapp.atsp;





public class klass13Tachycardiapalpitations extends AppCompatActivity {

private CoordinatorLayout coordinatorLayout;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.ly_13_tachycardiapalpitations);


    coordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator);



    CollapsingToolbarLayout collapsingToolbar = (CollapsingToolbarLayout) findViewById(R.id.ly_13_tachycardiapalpitations_collapsing);
    collapsingToolbar.setTitle("Tachycardia/Palpitations");


}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.menu_home, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.action_settings:
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

}

like image 389
Football Avatar asked Nov 20 '25 18:11

Football


1 Answers

Add on your: android.support.design.widget.CollapsingToolbarLayout

app:expandedTitleTextAppearance="@style/HeaderTitleStyle"

Create on your: Styles.xml

  <style name="HeaderTitleStyle" parent="@android:style/TextAppearance">
    <item name="android:textColor">#FFFFFF</item>
    <item name="android:textSize">20sp</item>
    <item name="android:singleLine">false</item>
  </style>
like image 57
Rafael Lazarin Avatar answered Nov 23 '25 18:11

Rafael Lazarin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!