【发布时间】:2018-11-20 04:39:44
【问题描述】:
我有 FAB 并试图将 drawable(round_drawable.xml) 填充到我的整个工厂,但 drawable 当前显示在左上角,如下所示,
我尝试了Setting src and background for FloatingActionButton 的解决方案,但它不起作用,添加了来自其他来源的大多数属性,但scaleType, src, background 都不起作用。
如何使用 round_drawable 填充 FAB?
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab"
android:layout_width="100dp"
android:layout_height="95dp"
android:scaleType="fitXY"
app:backgroundTint="@color/white"
android:src="@drawable/round_drawable"
android:backgroundTintMode="src_atop"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
</android.support.constraint.ConstraintLayout>
round_drawable.xml
@drawable/right是右箭头的png图像。
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:innerRadius="50dp"
android:shape="oval">
<corners android:radius="10dp" />
<gradient
android:angle="45"
android:endColor="#D425B5"
android:startColor="#EBF928" />
</shape>
</item>
<item
android:bottom="5dp"
android:left="5dp"
android:right="5dp"
android:top="5dp">
<bitmap
android:gravity="center"
android:src="@drawable/right" />
</item>
</layer-list>
【问题讨论】:
-
你的代码对我来说工作正常check screenshot
-
@NileshRathod 那么我的问题是什么?支持库??还是别的什么?
标签: android android-drawable floating-action-button