2014-10-22 86 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