我正在使用支持库v21中的新工具栏更新我的应用程序.我的问题是,如果我没有设置"高程"属性,工具栏不会投射任何阴影.这是正常行为还是我做错了什么?
我的代码是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/my_awesome_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="4dp"
android:minHeight="?attr/actionBarSize"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<FrameLayout
android:id="@+id/FrameLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent">
.
.
.
Run Code Online (Sandbox Code Playgroud)
在我的Activity - OnCreate方法中:
Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
setSupportActionBar(toolbar);
Run Code Online (Sandbox Code Playgroud) android material-design android-5.0-lollipop android-toolbar
有没有办法View在前棒棒糖设备中添加高程而不将它们包裹在CardView?
首先,我知道之前已经问过这个问题,但之前没有得到回答.我希望有人能给我一个答案.
在我的应用程序中,我使用Appcompat_v7(API 21)中的工具栏.这是我的代码:
<android.support.v7.widget.Toolbar
style="@style/DarkActionbarStyle"
android:id="@+id/toolBar"
android:layout_width="match_parent"
android:layout_height="@dimen/actionbar_height" />
Run Code Online (Sandbox Code Playgroud)
这是我使用的ToolBar样式:
<style name="DarkActionbarStyle" parent="@style/Widget.AppCompat.Toolbar">
<item name="android:background">?attr/colorPrimary</item>
<item name="titleTextAppearance">@style/ActionBarTitle</item>
<item name="android:elevation">2dp</item>
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
<item name="theme">@style/ThemeActionBarDark</item>
</style>
<style name="ThemeActionBarDark" parent="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<item name="actionBarItemBackground">@drawable/btn_dark_orange</item>
<item name="selectableItemBackground">@drawable/btn_dark_orange</item>
</style>
Run Code Online (Sandbox Code Playgroud)
问题是,提升前棒棒糖不起作用.所以我的问题是:棒棒糖设备上的工具栏下是否有阴影?
android toolbar shadow android-appcompat android-5.0-lollipop
我想在自定义布局元素中使用高程,我想使用默认操作栏高程值在XML中设置该元素的值.我找不到用XML获取它的方法,我想避免调用getElevation()代码.有小费吗?
我从新的appcompat中添加了新的材质设计操作栏,并使用了新的工具栏小部件.我在xml的工具栏上设置了自定义背景但我的问题是没有显示操作栏的阴影.你知道怎么做吗?
工具栏代码
<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/my_awesome_toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="@drawable/ab_background_textured"
app:theme="@style/MyTheme"
app:popupTheme="@style/MyTheme.Popup"/>
Run Code Online (Sandbox Code Playgroud)
MyTheme风格
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<item name="android:textColorSecondary">#ffff8800</item>
</style>
Run Code Online (Sandbox Code Playgroud)
MyTheme.Popup风格
<style name="MyTheme.Popup" parent="ThemeOverlay.AppCompat.Dark">
<item name="android:textColor">#ffffff</item>
</style>
Run Code Online (Sandbox Code Playgroud)
更新
就像@Justin鲍威尔建议我添加actionBarStyle我的主题,但仍然没有投影.
MyTheme风格(更新)
<style name="MyTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textColorPrimary">@color/abc_primary_text_material_dark</item>
<item name="actionMenuTextColor">@color/abc_primary_text_material_dark</item>
<item name="android:textColorSecondary">#ffff8800</item>
<item name="android:actionBarStyle">@style/Widget.AppCompat.Light.ActionBar.Solid.Inverse</item>
</style>
Run Code Online (Sandbox Code Playgroud)