我需要创建一个带有白色边框并填充纯色(蓝色或灰色)的 FAB。
xml
<android.support.design.widget.FloatingActionButton
android:id="@+id/myFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
我尝试了 How to change android design support library FAB Button border color? 中建议的公认解决方案.但是没有用(没有添加边框)。
非常感谢任何帮助。
最佳答案
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/rl_content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/circle_white_border"
android:padding="3dp">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:elevation="0dp"
app:elevation="0dp"
app:fabSize="normal" />
</LinearLayout>
</RelativeLayout>
float 操作按钮的背景
in the drawable fab_border.xml
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:innerRadius="0dp"
android:shape="ring"
android:thicknessRatio="2"
android:useLevel="false">
<stroke
android:width="4dp"
android:color="@android:color/white" />
</shape>
关于android - FloatingActionButton 的白色边框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45641713/