Android:如何像这样定制应用程序栏(动作栏)?
我需要完全像这样,我看到一些例子,以自定义工具栏,但不能设计,如何使用这些梯度和所有Android:如何像这样定制应用程序栏(动作栏)?,android,android-actionbar,android-appbarlayout,Android,Android Actionbar,Android Appbarlayout,我需要完全像这样,我看到一些例子,以自定义工具栏,但不能设计,如何使用这些梯度和所有 创建一个drawable类似的drawable <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle"> <gradient android:centerColor="
创建一个
drawable
类似的drawable
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<gradient
android:centerColor="@color/app_blue_color"
android:endColor="@color/app_dark_blue_color"
android:startColor="@color/app_dark_blue_color" />
<!--<corners-->
<!--android:bottomLeftRadius="5dp"-->
<!--android:bottomRightRadius="5dp"-->
<!--android:topLeftRadius="5dp"-->
<!--android:topRightRadius="5dp" />-->
<stroke
android:width="0.7dp"
android:color="@color/app_blue_color" />
将此设置为自定义工具栏的背景
创建工具栏布局
<?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"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@drawable/toolbarDrawable"
android:gravity="top"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:contentInsetStartWithNavigation="0dp"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/AppTheme"
app:theme="@style/ToolbarColoredBackArrow">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center_vertical">
<ImageView
android:id="@+id/RefreshButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:adjustViewBounds="true"
android:padding="8dp"
android:src="@drawable/plus_icon"
android:visibility="gone" />
<TextView
android:id="@+id/toolbarName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/margin_10"
android:gravity="center"
android:text=""
android:textColor="@color/white"
android:textSize="13sp"
android:textStyle="bold|italic"
android:visibility="visible" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
在您的活动中,包括使用
<include
android:id="@+id/toolbar"
layout="@layout/toolbar_title" />
// toolbar_tile is my toolbar layout name
//工具栏\u tile是我的工具栏布局名称
您尝试过什么吗?可能重复了至少一次关于该主题的研究,如果您没有找到任何解决方案,请在此处提问,在这个问题中没有发现任何问题,只需创建一个具有渐变效果的绘图,并将该绘图设置为背景toolbar@VivekMishra对我定制了工具栏并成功创建了,但事情是设计意味着黑色的阴影和所有,怎么办that@suhas根据你的需要选择颜色是的,我知道如何创建自己的可绘制文件。谢谢@Shaifali和Shashwat