2015-12-21 37 views
5

我正在使用Android Studio進行編程。目標SDK是23和最低SDK是15我如何刪除android動作欄Shadow

我試圖刪除我的操作欄和我的滑動標籤佈局之間的陰影。但我無法。

注意:陰影僅在Android 5及更高版本中可見。

我已經使用<item name="elevation">0dp</item>getSupportActionBar().setElevation(0); 但還是不起作用......

enter image description here

我Style.xml

<resources> 

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 



<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 



<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> 
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light"> 
    <item name="elevation">0dp</item> 
</style> 

我的風格V21

<resources>> 
<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
    <item name="android:windowDrawsSystemBarBackgrounds">true</item> 
    <item name="android:statusBarColor">@android:color/transparent</item> 
</style> 

我MainActivity.java onCreateCode:

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 

    getSupportActionBar().setElevation(0); 

....

回答

9

你錯過了你的風格的前綴。

<item name="android:elevation">0dp</item> 

這就是說,你也可以將它直接在AppBarLayout

<android.support.design.widget.AppBarLayout 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:elevation="0dp" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

或者我喜歡做的是移動SlidingTabLayoutAppBarLayout什麼,所以影子出現在它下面:

<android.support.design.widget.AppBarLayout 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:theme="@style/AppTheme.AppBarOverlay"> 

    <android.support.v7.widget.Toolbar android:id="@+id/toolbar" 
     android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" 
     android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" 
     /> 

    <com.ccswe.SmokingLog.views.widgets.SlidingTabLayout 
     android:id="@+id/sliding_tabs" 
     android:layout_width="wrap_content" 
     android:layout_height="@dimen/tab_layout_height" 
     /> 

</android.support.design.widget.AppBarLayout> 

Output from last code snippet

+0

謝謝男人謝謝你loooooooooooooot 我感動的選項卡appbar也和其固定 謝謝你,祝你好運 –

+0

你」歡迎。如果它解決了您的問題,請不要忘記接受或註冊我的答案。 –

+0

感謝它的工作 –

3

嘗試添加標高與支持庫的幫助下設置爲0

<android.support.design.widget.AppBarLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:elevation="0dp" 
    android:theme="@style/AppTheme.AppBarOverlay">