0

I have this toolbar :

   <android.support.design.widget.AppBarLayout
            android:id="@+id/appbar"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.design.widget.CollapsingToolbarLayout
                android:id="@+id/collapsingtoolbarly"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:fitsSystemWindows="true"
                app:contentScrim="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|snap">

                <android.support.v7.widget.Toolbar
                    android:id="@+id/my_toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize"
                    android:background="?attr/colorPrimary"
                    android:elevation="4dp"
                    android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
                    app:layout_collapseMode="pin"
                    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
                    />

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

I have this in Java :

Toolbar myToolbar = (Toolbar) findViewById(R.id.my_toolbar);
        myToolbar.setTitleTextColor(0xffffffff);
        myToolbar.setBackgroundColor(0xffff0000);
        setSupportActionBar(myToolbar);
        getSupportActionBar().setTitle("My app");

When I run the app, toolbar is showing but not the Title. How can I show title? Thanks.

jason
  • 6,962
  • 36
  • 117
  • 198

3 Answers3

3

You could include this line in CollapsingToolbarLayout

app:titleEnabled="false"
Chenna19
  • 31
  • 2
0

Try setting the title from app manifest file. Try

<activity
        android:name=".MainActivity"
        android:label="@string/title_activity"/>

Then set the String value property inside your String value resource.

ribads
  • 393
  • 3
  • 7
0

Check with below link and it's relative answers.

Title, etc. not showing in Android Toolbar

Hope this will help you !!

Community
  • 1
  • 1
Jay Rathod
  • 11,131
  • 6
  • 34
  • 58