2014-10-22 70 views

回答

0

首先,您需要创建一个扩展现有操作栏主题并将android:windowActionBarOverlay属性设置为true的自定义主题。

<resources> 
    <!-- the theme applied to the application or activity --> 
    <style name="CustomActionBarTheme" 
      parent="@android:style/Theme.Holo"> 
     <item name="android:windowActionBarOverlay">true</item> 
    </style> 
</resources> 

,并添加你的布局如下:

android:paddingTop="?android:attr/actionBarSize" 

例子:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingTop="?android:attr/actionBarSize"> // <==== add this one 
    ... 
</RelativeLayout> 

了解更多关于this

+0

在这种情况下,ActionBar重叠了RelativeLayout。可以点击ActionBar下的布局,点击ActionBar? – 2014-10-22 04:05:03

0

如果您需要在主要内容上显示一些内容,PopupWindow将是最佳选择。

+0

是的,但在这种情况下,我需要此项目是活动布局的一部分,而不是弹出窗口。 – 2014-10-22 03:44:12

+0

为什么?这不仅仅是弹出式菜单,您可以配置它的行为,例如,如果点击它,它可以在视图和点击之间触摸。顺便说一句,你没有很多选择来完成这种行为。 – Bracadabra 2014-10-22 03:48:58