2017-02-11 133 views
0

我正在做我的应用程序的最后一次接触,并注意到我的工具栏上运行5.0和更高版本的设备上的奇怪行为。在低于5.0的设备上,我的图像下方没有奇怪的线条,我为工具条设置了backgroundDrawable,但在设备5.0和更高版本上,似乎工具栏在图像后面可见。我尝试了很多方法,我主要在这里找到了stackoverflow,但似乎没有任何工作。我尝试了transparent背景,但没有奏效。我也用transparent背景创建了自定义主题,但那不起作用。以下是图像: Bellow Lollipop Lollipop and aboveAndroid棒棒糖5.0上的工具栏阴影问题

代码:

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:background="?attr/colorPrimary" 
    android:layout_height="match_parent"> 
<android.support.design.widget.AppBarLayout 
    android:id="@+id/appbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fitsSystemWindows="true"> 
    <android.support.v7.widget.Toolbar 
     android:id="@+id/toolBar" 
     android:layout_width="match_parent" 
     android:layout_height="100dp" 
     app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
     app:popupTheme="@style/ThemeOverlay.AppCompat.Light" 
     android:background="@android:color/transparent" 
     app:layout_scrollFlags="scroll|enterAlways"> 
     <ImageView 
      android:id="@+id/icon" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:src="@drawable/ic_logo_final" 
      android:layout_gravity="center" 
      android:gravity="center" 
      android:layout_marginRight="50dp" 
      android:layout_marginTop="5dp" 
      android:layout_marginBottom="15dp" 
      /> 
    </android.support.v7.widget.Toolbar> 
</android.support.design.widget.AppBarLayout> 
    <android.support.v7.widget.RecyclerView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    android:id="@+id/recyclerView"> 
    </android.support.v7.widget.RecyclerView> 
    </android.support.design.widget.CoordinatorLayout> 

在此先感谢。

+0

讨厌投票时没有解释!如果你知道一些事情,请指导我,并将问题标记为重复,如果它真的是,但提供解释。似乎投票应该是罕有的特权。 – Yupi

回答

1

试试这个从工具栏中删除阴影:

<style name="MyAppTheme" parent="android:Theme.Holo.Light"> 
    <item name="android:windowContentOverlay">@null</item> 
</style> 

AppBarLayout还设置app:elevation="0dp"appbar

+0

谢谢!这解决了问题。 – Yupi

1

这是由于工具栏的阴影特征躲在阴影..所以把它隐藏..

尝试在“android.support.design.widget.AppBarLayout”中应用"app:elevation="0dp"来解决此问题。

+0

谢谢!赞同您的评论。 – Yupi

相关问题