[英]Is it possible to set an icon on top of a Floating action button android
button tint to keep background color in your case it will be orange src will be the above image which u have in white a dish container you can use a frame layout and make another button and align than to top right 按钮颜色,以保持背景颜色为您的情况,它将是橙色src将是您在白色的白色容器中的上面的图像,您可以使用框架布局并制作另一个按钮,然后比右上角对齐
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_new"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add_white"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:backgroundTint="@color/red"
android:layout_margin="@dimen/margin_10"/>
In your coordinator layout please add these and you'll have the desired effect 在您的协调器布局中,请添加这些,您将获得理想的效果
<android.support.design.widget.FloatingActionButton android:id="@+id/panic_fab" android:layout_width="60dp" android:layout_height="60dp" android:layout_gravity="bottom|right" android:layout_marginBottom="15dp" android:layout_marginRight="15dp" android:background="@drawable/clip_gradient" android:elevation="12dp" android:src="@drawable/ic_error_outline_black_24dp" app:elevation="6dp" app:pressedTranslationZ="12dp" /> <android.support.design.widget.FloatingActionButton android:id="@+id/panic_fab1" android:layout_width="20dp" android:layout_height="20dp" android:layout_gravity="bottom|right" android:layout_marginBottom="15dp" android:layout_marginRight="15dp" android:background="#fff" android:elevation="12dp" android:src="@drawable/notification" app:elevation="8dp" app:pressedTranslationZ="12dp" />
i have tested this hope this will work for you. 我已经测试过这一希望,它将对您有用。 Do some changes acording to ua requirements
根据UA要求进行一些更改
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_new"
android:layout_width="60dp"
android:layout_height="@dimen/margin_60"
android:src="@drawable/ic_add_white"
android:padding="@dimen/margin_20"
android:backgroundTint="@color/red"
android:layout_margin="@dimen/margin_10"/>
<android.support.design.widget.FloatingActionButton
android:id="@+id/add_nw"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="right"
android:layout_marginTop="@dimen/margin_5"
android:backgroundTint="@color/blue"
android:src="@drawable/ic_add_white" />
</FrameLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.