Reputation:
I want to add Textview with image like below image instead of application name:
I dont want to remove menu image . i just want to remove applicatoin name from actionbar and put this kind of textview and on that click i want to show toast.
How can i do that ?
Upvotes: 0
Views: 2655
Reputation: 254
You can make your own app bar xml. Include the app bar where you want to show using include tag. Don't forget to define your theme as NoActionBar in styles.
<include
layout="@layout/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
Here the toolbar xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/header_color"
android:elevation="4dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:paddingTop="5dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:orientation="horizontal"
android:gravity="center">
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3.5"
android:orientation="horizontal"
android:gravity="center_vertical">
<TextView
android:id="@+id/txtTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageViewNotification" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:src="@drawable/tab_bar_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageViewlogin" />
</LinearLayout>
</LinearLayout>
Upvotes: 1
Reputation: 1
ActionBar action = getSupportActionBar(); //get the actionbar
action.setCustomView(R.layout.your_bar);//add the custom view
action.setDisplayShowTitleEnabled(false); //hide the title
after it , make layout with what you wants like textView, imageVie etc.. Hope helped u :D
Upvotes: 0