i have with my toolbar xml file which show how does my toolbar look Like :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar1"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:showAsAction="ifRoom|withText"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="65dip"
android:layout_height="65dip"
android:id="@+id/showevents"
android:layout_gravity="right"
android:textSize="12sp"
android:background="@drawable/cart"
android:textColor="#000000"
android:layout_marginRight="52dp"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="52dp"/>
<TextView
android:id="@+id/textOne"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@id/showevents"
android:layout_alignRight="@+id/showevents"
android:layout_marginRight="0dp"
android:layout_marginTop="5dp"
android:paddingBottom="1dp"
android:paddingLeft="10dp"
android:paddingRight="4dp"
android:text=""
android:textColor="#FFF"
android:textSize="16sp"
android:textStyle="bold"
android:layout_gravity="right"
android:background="@drawable/badge_circle"
android:layout_alignParentRight="false" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
Here is my Activity code to access Toolbar:
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar1);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setTitle("Product Details");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
my Question is that Image and text both are shown on toolbar but why Title is not showing.is there any way to show the title? Any help would be appreciated in advanced..
if you are customizing the toolbar then customize completely. Add one more text view in relative layout for title and setDisplayShowTitleEnabled to false.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.