[英]How to add Floating Action button with appcompact
我最近由android sdk更新到了新的android 5.0
并试图使用appcompact添加浮动操作按钮(FAB)。
我不想使用任何类型的外部库
我如何通过appcompact将FAB按钮添加到按项目
您不需要任何特殊的库即可制作FAB。 创建一个扩展ImageButton的类,并在onTouch方法中上下缩放视图。
android现在在其设计上具有浮动操作按钮:
只需在gradle文件上添加compile 'com.android.support:design:22.2.0'
并添加
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="68dp"
android:layout_marginRight="10dp"
android:clickable="true"
android:background="@mipmap/icon_plus_button"
app:layout_anchor="@id/mainContent"
app:layout_anchorGravity="bottom|right|end"
app:fabSize="mini"
app:backgroundTint="#5894EF"
app:elevation="6dp"
app:rippleColor="@android:color/transparent"
app:pressedTranslationZ="12dp"/>
在您的xml布局上。 希望这对任何人有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.