我将这个半透明的渐变背景添加到工具栏,这样按钮在任何背景上都很明显,但我想知道如何在按钮本身下方制作阴影而不是我所做的?
谢谢
编辑
所以我意识到最简单的方法是设置 Drawable Resources。
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_home);
和
<style name="AppTheme" parent="parent_theme">
<item name="actionModeShareDrawable">@drawable/ic_share</item>
</style>
我下载了 Material Vector 资源,在 Adobe Illustrator 中添加了阴影,并将其导入到 PNG。但是 Android Studio 的图像 Assets /操作栏和选项卡图标搞砸了我不明白为什么 - 它删除了阴影,即使使用自定义“主题”颜色也不同所以我自己做了不同的 dpi 图像大小,这就是我得到。这正是我想要的
最佳答案
好吧,我不知道如何用简单的按钮来做,如果你可以用 FloatingActionButton
改变 Button
你可以使用 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
的知识,它可以让您添加一些不错的效果,例如高程/阴影和 Material 库中的其他好东西。
希望它能让你的开发更简单,让你的应用更漂亮。
关于Android 工具栏按钮阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34597081/