Android 工具栏按钮阴影
Android Toolbar buttons shadow
我将这个半透明的渐变背景添加到工具栏,这样按钮在任何背景上都很明显,但我想知道如何在按钮下方制作阴影而不是我所做的?
谢谢
编辑
所以我意识到最简单的方法是设置一个 Drawable Resources。
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_home);
和
<style name="AppTheme" parent="parent_theme">
<item name="actionModeShareDrawable">@drawable/ic_share</item>
</style>
我下载了 Material 矢量资源,在 Adobe Illustrator 中添加了阴影,并将其导入 PNG。但是 Android Studio 的图像 Asset/Action 栏和选项卡图标搞砸了我不明白为什么 - 它删除了阴影并且即使使用自定义 'Theme' 颜色也不同所以我做了不同的 dpi我自己调整图像大小,这就是我得到的。这正是我想要的
好吧,我不知道如何用简单的按钮来做,如果你能把 Button
改成 FloatingActionButton
你可以用 elevation
来制作阴影。
Floating Action Button
(FAB
) is simply a circle button with some drop shadow that unbelieveably could change the world of design. No
surprise why it becomes a signature of Material Design
. So let's start
with this thing. Add FAB
in layout file with FloatingActionButton
and wrap it with FrameLayout
since it needs some parent to make it aligned at bottom right position of the screen.
和
The shadow depth is automatically set to the best practices one, 6dp
at idle state and 12dp
at pressed state. Anyway you are allowed to
override these values by defining app:elevation
for idle state's
shadow depth and app:pressedTranslationZ
for press state's.
From: http://inthecheesefactory.com/blog/android-design-support-library-codelab/en
当然,您可以通过添加您的图标来自定义。我很确定,按钮上的 play
图标在 Material Design
库中。
你也可以在这里抓取:https://design.google.com/icons/
要恢复,我建议您多了解一些 FloatingActionButton
,这使您可以添加一些不错的效果,例如 elevation/shadow 和 Material 库中的其他好东西。
希望它能让你的开发更简单,让你的应用更漂亮。
我将这个半透明的渐变背景添加到工具栏,这样按钮在任何背景上都很明显,但我想知道如何在按钮下方制作阴影而不是我所做的?
谢谢
编辑
所以我意识到最简单的方法是设置一个 Drawable Resources。
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_home);
和
<style name="AppTheme" parent="parent_theme">
<item name="actionModeShareDrawable">@drawable/ic_share</item>
</style>
我下载了 Material 矢量资源,在 Adobe Illustrator 中添加了阴影,并将其导入 PNG。但是 Android Studio 的图像 Asset/Action 栏和选项卡图标搞砸了我不明白为什么 - 它删除了阴影并且即使使用自定义 'Theme' 颜色也不同所以我做了不同的 dpi我自己调整图像大小,这就是我得到的。这正是我想要的
好吧,我不知道如何用简单的按钮来做,如果你能把 Button
改成 FloatingActionButton
你可以用 elevation
来制作阴影。
Floating Action Button
(FAB
) is simply a circle button with some drop shadow that unbelieveably could change the world of design. No surprise why it becomes a signature ofMaterial Design
. So let's start with this thing. AddFAB
in layout file withFloatingActionButton
and wrap it withFrameLayout
since it needs some parent to make it aligned at bottom right position of the screen.
和
The shadow depth is automatically set to the best practices one,
6dp
at idle state and12dp
at pressed state. Anyway you are allowed to override these values by definingapp:elevation
for idle state's shadow depth andapp:pressedTranslationZ
for press state's.From: http://inthecheesefactory.com/blog/android-design-support-library-codelab/en
当然,您可以通过添加您的图标来自定义。我很确定,按钮上的 play
图标在 Material Design
库中。
你也可以在这里抓取:https://design.google.com/icons/
要恢复,我建议您多了解一些 FloatingActionButton
,这使您可以添加一些不错的效果,例如 elevation/shadow 和 Material 库中的其他好东西。
希望它能让你的开发更简单,让你的应用更漂亮。