【发布时间】:2016-02-27 18:24:57
【问题描述】:
我有一个工具栏布局和 mainlayout 。 在我的主布局中,我包含了我的工具栏布局:
工具栏布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/PrimaryButtonsAndHeadscolor"
android:titleTextAppearance="@color/ColorPrimaryDark"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:elevation="8dp">
</android.support.v7.widget.Toolbar>
我的主要布局(带有工具栏的部分):
<LinearLayout
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainScreen"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
>
>
<include
android:id="@+id/tool_bar"
layout="@layout/tool_bar"
></include>
</LinearLayout>
在“预览”屏幕上的 andorid studio 上,我的工具栏投下了阴影,但是当我在我的设备上运行它时却没有。 我知道海拔属性适用于在 api 21+ 上运行的设备,我使用的是 lgg-4 api22,因此它应该在工具栏下方投射阴影(我还在其他应用程序中看到工具栏下方的阴影)。 我在做什么?
谢谢!
【问题讨论】:
-
不工作:/,现在预览中也没有阴影
-
Android 5.1,我应该验证什么?
-
你可以尝试设置
requestWindowFeature(Window.FEATURE_ACTION_BAR_OVERLAY); -
我刚刚将此布局插入到一个新的空白项目中,它工作得很好,高程阴影显示。在 6.0.1 上测试
-
所以我的设备有问题?
标签: java android toolbar shadow elevation