我想你已经看到了新的Android设计指南,新的"浮动动作按钮"又名"FAB"
例如这个粉红色的按钮:
我的问题听起来很愚蠢,我已经尝试了很多东西,但是将这个按钮放在两个布局的交叉点上的最佳方法是什么?
在上面的例子中,这个按钮完全位于我们可以想象的ImageView和relativeLayout之间.
我已经尝试了很多调整,但我确信有一个正确的方法来做到这一点.
我想创建一个浮动操作按钮(将项目添加到列表视图),如谷歌日历,保持与棒棒糖前Android版本(5.0之前)的兼容性.
我创建了这个布局:
活动main_activity.xml:
<LinearLayout ... >
<include
layout="@layout/toolbar"/>
<RelativeLayout ... >
<!-- My rest of the layout -->
<!-- Floating action button -->
<ImageButton style="@style/AppTheme"
android:layout_width="60dp"
android:layout_height="60dp"
android:text="New Button"
android:id="@+id/button"
android:src="@drawable/ic_fab"
android:background="@drawable/fab"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="24dp"
android:layout_marginRight="24dp"/>
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
可绘制的fab.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="#ffa48bc0"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
样式styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">#ff1d79b1</item>
<item name="colorPrimaryDark">#ff084d95</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
结果类似,但没有阴影,材料设计的特点:
日历的浮动操作按钮:
我的应用程序的浮动操作按钮:
如何将阴影添加到我的按钮?
我已经使用了属性提升,但不起作用
我在我的布局文件中使用来自新的Design Support库22.2.0的android.support.design.widget.FloatingActionButton.它工作正常但它在API级别17下方显示了一个方形按钮
我的问题围绕Android Material Design中引入的浮动操作按钮.
有很多库在GitHub上提供这个组件:
但我的问题是:
是否有一个本机组件,其最后一个版本android.support.vX
是为其构建的Floating action button
?
组件如:
android android-support-library material-design floating-action-button android-design-library