Reputation: 7164
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
Reputation: 31
You could include this line in CollapsingToolbarLayout
app:titleEnabled="false"
Upvotes: 3
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
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