java - 如何使工具栏边缘透明?
问题描述
我有一个位于选项卡布局顶部的工具栏。这两个都将使用相同的颜色渐变作为背景。我试图摆脱工具栏或选项卡布局上的边缘,以便它们融合在一起,因为现在它们之间有一条黑线。有什么方法可以使它们之间的这条线透明吗?我以前在 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>
解决方案
包括ToolBar
里面的AppBarLayout
,上面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>
推荐阅读
- c# - 在泛型中使用的推断类型被其他泛型继承
- arrays - 如何从Ruby中的数组中只选择某些元素?
- flutter - 参数类型“字符串?” 不能分配给参数类型“字符串”
- javascript - Vis.js 网络不显示节点之间的多行
- ios - 将 UIFont 对象从 React-Native 传递给 Swift
- linux - 权限被拒绝 - 即使在拥有所有权的组中
- angular - 使用角度从firestore嵌套集合中获取数据
- machine-learning - 我们可以在训练模型时从多个输入中获得单个输出吗?
- bash - 在不消耗数据的情况下测试输入流是否为空
- c - c中的指针尊重