答案 0 :(得分:1)
您可以制作自己的应用栏xml。使用include标记包含要显示的应用栏。别忘了在样式中将主题定义为NoActionBar。
<include
layout="@layout/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
这里是工具栏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>
答案 1 :(得分:0)
ActionBar action = getSupportActionBar(); //get the actionbar
action.setCustomView(R.layout.your_bar);//add the custom view
action.setDisplayShowTitleEnabled(false); //hide the title
之后,使用textView,imageVie等进行布局。 希望帮助你:D