jason
jason

Reputation: 7164

Toolbar title not showing in Android

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.

Upvotes: 0

Views: 3316

Answers (3)

Chenna19
Chenna19

Reputation: 31

You could include this line in CollapsingToolbarLayout

app:titleEnabled="false"

Upvotes: 3

Jay Rathod
Jay Rathod

Reputation: 11245

Check with below link and it's relative answers.

Title, etc. not showing in Android Toolbar

Hope this will help you !!

Upvotes: 0

ribads
ribads

Reputation: 393

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.

Upvotes: 0

Related Questions