2015-12-21 72 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">