如何使工具栏边缘透明?



>我有一个工具栏位于选项卡布局的顶部。这两者都将使用相同的颜色渐变作为背景。我正在尝试摆脱工具栏或选项卡布局上的边缘,以便它们混合在一起,因为现在它们之间有一条黑线。有没有办法使它们之间的这条线透明?我以前在Xcode上做过。

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:openDrawer="start"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/menu_gradient"
android:id="@+id/content">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/transparent"
android:id="@+id/main_toolbar"
android:elevation="4dp"
app:titleTextColor="#ffffff"
tools:ignore="MissingConstraints"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/logos_round" />
</android.support.v7.widget.Toolbar>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:background="@drawable/menu_gradient"
android:layout_height="wrap_content">
<android.support.design.widget.TabLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/tabs"
android:elevation="5dp"
android:background="@drawable/transparent"
app:tabTextColor="@color/colorPrimary"
app:tabTextAppearance="@style/customTabText"
app:tabMode="fixed">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1">
</android.support.v4.view.ViewPager>
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:menu="@menu/activity_main_drawer"
android:background="@color/colorPrimary"/>
</android.support.v4.widget.DrawerLayout>

AppBarLayout中包含ToolBar,上面TabLayout如下:

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:background="@drawable/menu_gradient"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/transparent"
android:id="@+id/main_toolbar"
android:elevation="4dp"
app:titleTextColor="#ffffff"
tools:ignore="MissingConstraints"
android:theme="@style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="@mipmap/logos_round" />
</android.support.v7.widget.Toolbar>

<android.support.design.widget.TabLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/tabs"
android:elevation="5dp"
android:background="@drawable/transparent"
app:tabTextColor="@color/colorPrimary"
app:tabTextAppearance="@style/customTabText"
app:tabMode="fixed">
</android.support.design.widget.TabLayout>
</android.support.design.widget.AppBarLayout>

最新更新