2012-01-04 69 views
2

目前,我有以下應用程序,它由一個ActionBar和一個自定義視圖組成。它看起來像這樣在操作欄和自定義相機視圖上投下陰影

enter image description here

我儘量做到對

  1. 操作欄陰影效果(來自ActionBarSherlock使用庫)
  2. 自定義相機視圖

通過使用「 9補丁「技術,我可以在操作欄上放置陰影,但不能在自定義視圖中放置陰影。

這是我正在使用的技術。我具體windowContentOverlay到「9補丁」圖像。根據文件,這是什麼windowContentOverlay用於。

該Drawable覆蓋在窗口的內容 的前景區域,通常用於放置標題下的陰影。

我希望操作欄和自定義視圖都被歸類爲Drawable。通過具有橫跨整個活動以下樣式

值/ styles.xml

<resources> 
    <style name="AppTheme" parent="@style/Theme.Sherlock.Light"> 
     <item name="android:windowContentOverlay">@drawable/actionbar_shadow</item> 
    </style> 
</resources> 

的AndroidManifest.xml

<application android:theme="@styles/AppTheme"> 

actionbar_shadow.9.png

enter image description here

但是,我只能在操作欄上看到陰影,但不能看到我的自定義相機視圖。

有關信息,這裏是我如何佈局我唯一的活動。

佈局/ main.xml中

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" 
    android:gravity="center" > 

    <view xmlns:android="http://schemas.android.com/apk/res/android" 
     class="org.yccheok.gui.CustomView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
    /> 

</LinearLayout> 

我很納悶,爲什麼windowContentOverlay技術是可行的行動吧,但不是我的自定義相機的看法?

回答

3

您可以使用此下降動作條陰影:

<item name="android:windowContentOverlay">@null</item>