如何在appbarlayout内制作带有圆角和高程的工具栏?喜欢这张照片 [英] How to make toolbar with rounded corners and elevation inside appbarlayout? Like this picture
本文介绍了如何在appbarlayout内制作带有圆角和高程的工具栏?喜欢这张照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是我尝试创建带有圆角的工具栏的代码,如图所示.
This is my code that I try to create toolbar with rounded corners shown in picture.
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:background="@android:color/transparent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_actionbar" />
</android.support.design.widget.AppBarLayout>
bg_actionbar.xml
bg_actionbar.xml
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android" >
<solid android:color="@color/white" />
<corners android:radius="16dp" />
</shape>
推荐答案
在AppBarLayout
并将android:elevation="4dp"
设置为Toolbar
还将"android:layout_margin ="4dp""设置为工具栏,这将帮助您显示阴影.
And also set 'android:layout_margin="4dp"' to Toolbar which will help you to show shadow.
所以您的布局将是这样
<android.support.design.widget.AppBarLayout
android:id="@+id/appBar"
app:elevation="0dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
android:background="@android:color/transparent">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:elevation="4dp"
android:layout_margin="4dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_actionbar" />
这篇关于如何在appbarlayout内制作带有圆角和高程的工具栏?喜欢这张照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文