Toolbar title not showing in Android

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.

android
android-layout
android-toolbar
asked on Stack Overflow Feb 7, 2016 by jason

3 Answers

1

You could include this line in CollapsingToolbarLayout

app:titleEnabled="false"
answered on Stack Overflow Nov 19, 2020 by Chenna19
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.

answered on Stack Overflow Feb 7, 2016 by ribads
0

Check with below link and it's relative answers.

Title, etc. not showing in Android Toolbar

Hope this will help you !!

answered on Stack Overflow Feb 7, 2016 by Jay Rathod RJ • edited May 23, 2017 by Community

User contributions licensed under CC BY-SA 3.0