我正在尝试使用透明的工具栏渐变,但是没有任何效果.这是我的代码.
activity_main.xml(已更新)
<androID.support.design.Widget.CoordinatorLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" tools:context="com.amrat.MainActivity"> <androID.support.design.Widget.AppbarLayout androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:background="@drawable/gradIEnt" androID:theme="@style/Apptheme.AppbarOverlay" app:elevation="0dp"> <androID.support.v7.Widget.Toolbar androID:ID="@+ID/toolbar" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" androID:background="@drawable/gradIEnt" androID:layout_alignParentBottom="true" app:popuptheme="@style/Apptheme.PopupOverlay" /> </androID.support.design.Widget.AppbarLayout> <include layout="@layout/content_main" /></androID.support.design.Widget.CoordinatorLayout>
渐变文件
<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:shape="rectangle"> <gradIEnt androID:angle="270" androID:endcolor="#00ffffff" androID:startcolor="#ffffff" androID:type="linear" /></shape>
尝试这样做:
但是得到这个:
如果有人知道该怎么做,请帮助我.
更新
AndroIDManifest.xml
<activity androID:name=".activity.MainActivity" androID:theme="@style/Apptheme.transparent.NoActionbar" />
style.xml
<item name="colorPrimary">@androID:color/transparent</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="colorControlnormal">@color/light_grey_1</item> <item name="colorControlActivated">@color/orange_1</item> <item name="colorControlHighlight">@color/light_grey_2</item></style>
解决方法:
直接使用@androID:color / transparent.跟随这个-
工具栏布局-
<?xml version="1.0" enCoding="utf-8"?><androID.support.v7.Widget.Toolbar xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:app="http://schemas.androID.com/apk/res-auto" xmlns:tools="http://schemas.androID.com/tools" androID:ID="@+ID/toolbar" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize" androID:background="@drawable/background_toolbar_transparent" />
background_toolbar_transparent.xml
<?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID"> <gradIEnt androID:angle="270" androID:endcolor="@androID:color/transparent" androID:startcolor="@color/black_Alpha"/></shape>
使用Alphaon colors.xml添加颜色-
<color name="black_Alpha">#66000000</color>
总结 以上是内存溢出为你收集整理的java-透明渐变工具栏全部内容,希望文章能够帮你解决java-透明渐变工具栏所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)