我将我的Android应用程序更新为新的材质设计,但我还想在工具栏中添加一些阴影或高程.通过图像/ 9补丁似乎有一些(hacky)方法,但我想知道它是否可以通过支持库完成.(就像CardView可以有高程)
根据这一答案的另一个问题,这是通过包装可能Toolbar在AppBarLayout,但这并不为我工作.
我的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="@+id/Toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
</android.support.design.widget.AppBarLayout>
Run Code Online (Sandbox Code Playgroud)
我也尝试过通过XML和代码设置高程,但这也不起作用.
任何帮助,将不胜感激!提前致谢.
更新:
由于我在其他布局中包含了我的工具栏布局,因此下面是我的主要布局之一:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<include
layout="@layout/Toolbar" />
<fragment
class="OverAllField.XamarinAndroid.Fragments.Planning.PlanningFragment"
android:id="@+id/PlanningFragment"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)