2013-08-06 96 views
7

問題是以下問題:在我的一個活動中,我需要爲我的操作欄定製佈局,而唯一需要的方法是透明ActionBar在我的屏幕上。爲此,我將ActionBar標記爲疊加層,並將操作欄背景指定爲透明。這在使用Android> = 15時有效,但在14和更低版本中,ActionBar保持其底部邊界。我試圖將其刪除,但無濟於事。覆蓋時,ActionBar邊框不會消失

這裏是一幅畫看得更清楚:

在API 14: ActionBar on API 14

在API 16: ActionBar on API 16

設計如下:操作欄應該是透明的並且處於疊加模式,並且在它後面有背景+徽標

<ImageView 
android:id="@+id/action_bar_background" 
android:layout_width="match_parent" 
android:layout_height="@dimen/action_bar_accueil_total_height" 
android:layout_alignParentTop="true" 
android:contentDescription="@string/action_bar" 
android:scaleType="fitXY" 
android:src="@drawable/actionbar_logo_extended" /> 

<ImageView 
android:id="@+id/home_gallica_logo" 
android:layout_width="@dimen/largeur_logo_carrousel" 
android:layout_height="@dimen/action_bar_accueil_total_height" 
android:layout_alignParentTop="true" 
android:layout_centerHorizontal="true" 
android:contentDescription="@string/action_bar" 
android:src="@drawable/logo_fullcolor" /> 

一些精度:我使用ABS,但這似乎不是問題的根源,因爲切換到v7支持庫完全是一回事。

有沒有人有一個想法如何刪除此底部邊框?

+0

嗯,我想這是所有關於不同版本如何解釋'.png'圖片。你可以設置圖像的背景像背景的漸變。我會尋找我的假設。 – g00dy

+0

事實是,ActionBar應該是透明的(並在疊加層中),以便在下面看到圖像。 –

+0

好吧,讓我問你這個問題,如何在API 16上部分水平線消失 - 是長(寬)的圖像?而且我還注意到,在API 14上,您已經將徽標縮小了一倍,這會消失,但第二行是可見的。這讓我想知道 - 你能否在這裏粘貼資源,以便我可以看到它們 - 標識的圖像(在平鋪背景上,其大小),圖像(gradient.xml或普通圖像漸變) ActionBar +整個'xml'如果這不是問題? – g00dy

回答

3

繼諮詢和在評論中的Luksprog測試中,我在我的操作欄中爲此頁使用了Theme.Sherlock(而不是Theme.Sherlock.Light),並從我的舊主題中複製了我需要的設置。這似乎解決了這個問題,但我並不完全確定問題的根源。我可以給那些將要看到這個的人的唯一建議是使用Theme.Sherlock。

0

你可以通過調用hide()方法隱藏在操作欄:

ActionBar actionBar = getSupportActionBar(); 
actionBar.hide(); 

或者,如果你想永久隱藏它,你可以設置這個在您的清單:

<activity 
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" 
> 
+0

我不想完全隱藏我的動作欄,因爲我仍然需要按鈕。我只是想讓它完全透明(在16+而不是之前)。 –

+0

@Valentin羅徹:你的意思是這樣的:http://stackoverflow.com/questions/13726214/transparent-actionbar-custom-tabcolor –

+0

燁,但沒有TESE解決方案做了工作,爲這個確切的問題 –

3

我試圖做一個simple activity來展示行爲,但我沒有設法做到這一點。我用了一個Activity,主題Theme.Sherlock

android:theme="@style/Theme.Sherlock 

,並且使覆蓋(在onCreate()法):

requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); // Window from com.actionbarsherlock.view 
//... 
setContentView(content); 
ActionBar ab = getSupportActionBar(); 
ab.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));