2015-11-12 47 views
0

在我的應用程序中,我使用AppCompat v7使用ActionBar。我注意到在設備上的東西就像ActionBar(白色空格)左邊和右邊的填充。我有固定的使用該解決方案:唧唧在ActionBar全寬大屏幕(平板電腦)?

<resources> 

<!-- the theme applied to the application or activity --> 
<style name="AppTheme" 
    parent="Theme.AppCompat.Light.DarkActionBar"> 

    <!-- Support library compatibility --> 
    <item name="actionBarStyle">@style/MyActionBar</item> 
</style> 

<!-- ActionBar styles --> 
<style name="MyActionBar" 
    parent="Widget.AppCompat.Toolbar"> 

    <!-- Support library compatibility --> 
    <item name="contentInsetStart">0dp</item> 
    <!--<item name="background">@android:color/transparent</item>--> 
</style> 

一切正常,在我的手機(5英寸),但在大屏幕平板電腦等問題依然存在......爲什麼?

+0

使用使用工具欄... !!! –

+0

所以我必須重建我的應用程序?有沒有其他方法? – Mattiah85

回答

0

我認爲使用工具欄的答案,但如果有人不想在這裏重建一個應用程序是(那麼優雅)的解決方案:

使用:

ab.setCustomView(R.layout.actionbar_main); 

Toolbar parent =(Toolbar) ab.getCustomView().getParent(); 
parent.setContentInsetsAbsolute(0,0); 
parent.setBackgroundColor(Color.parseColor("#00A0D1")); 

,而不是使用

<item name="contentInsetStart">0dp</item> 

in style.xml

「奇怪的」填充仍然存在,但具有相同的公式喜歡ActionBar。 即使在大屏幕上,一切看起來都很好。

相關問題