如何在android中将小部件放置在操作栏上方?

如何在android中将小部件放置在操作栏上方?,android,Android,有人能帮我知道如何在android中把一个小部件放在ActionBar上面吗?我读过其他一些关于stackoverflow的类似查询,但它提到这是不可能的。下面是我正在尝试创建的屏幕。有人能告诉我如何把蓝色布局部分放在ActionBar上面吗?或者有其他方法实现这一点吗? 下面是我的xml文件 xml 但是,我没有得到所需的布局。标题布局在操作栏下方可见 所需布局: 您看到的蓝色栏是使用自定义视图的操作栏。查看如何自定义操作栏。在您的图像中,蓝色布局将取代操作栏,而不是位于其上方。请注意,您

有人能帮我知道如何在android中把一个小部件放在ActionBar上面吗?我读过其他一些关于stackoverflow的类似查询,但它提到这是不可能的。下面是我正在尝试创建的屏幕。有人能告诉我如何把蓝色布局部分放在ActionBar上面吗?或者有其他方法实现这一点吗? 下面是我的xml文件

xml

但是,我没有得到所需的布局。标题布局在操作栏下方可见

所需布局:

您看到的蓝色栏是使用自定义视图的操作栏。查看如何自定义操作栏。

在您的图像中,蓝色布局将取代操作栏,而不是位于其上方。请注意,您的设计,特别是居中标题,违反了Android设计指南。我建议您遵循Android指南,制作适当的ActionBar,而不是居中标题。您可以将顶部蓝色部分和选项卡作为操作栏的一部分,但由于您的选项卡似乎比屏幕上的空间要多,因此在布局中使用PagerTabStrip并将蓝色标题作为操作栏可能会更好。PagerTabStrip:公认的Commonware&Karakuri。说起来很苛刻,但这正是客户需要的。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:background="@android:color/black"
     >

    <LinearLayout
        android:id="@+id/header"
        android:layout_width="match_parent"
        android:layout_height="100dp" >
    </LinearLayout>

    <android.support.v4.view.ViewPager
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </android.support.v4.view.ViewPager>

</LinearLayout>