FAB图标不填充按钮

问题描述 投票:0回答:3

我的布局怎么样导致浮动动作src图标不扩展以填充按钮的整个视图?

我想也许那个app:borderWidth="0dp"会解决这个问题,但事实并非如此。加号图标仍然小于按钮(红色区域)。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:app="http://schemas.android.com/apk/res-auto"
                android:id="@+id/cat"
                android:layout_width="match_parent"
                android:layout_height="match_parent">

    <ScrollView
        android:id="@+id/scrollview"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id="@+id/chordButtons"
                android:orientation="vertical"  >
            </LinearLayout>

            <android.support.design.widget.FloatingActionButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="bottom"
                android:layout_margin="16dp"
                android:clickable="true"
                app:borderWidth="0dp"
                android:src="@drawable/ic_add_circle_outline_black_24dp"/>
        </LinearLayout>

    </ScrollView>

</RelativeLayout> 

enter image description here

android xml material-design floating-action-button
3个回答
1
投票

您使用的是错误的图标。你的晶圆厂表现得像它应该的那样。看看材料guidelines

您应该使用this来实现与Google Calendar应用程序中类似的工厂设计,而不是该图标。


0
投票

将属性app:useCompatPadding="false"添加到FloatingActionButton

要么,

您可以使用没有外圈的不同+图标。使用this图标。

要么,

您可以使用第三方库com.github.clans.fab.FloatingActionButton来获得所需的输出。

这是一个例子:

<com.github.clans.fab.FloatingActionButton
    xmlns:fab="http://schemas.android.com/apk/res-auto"
    android:id="@+id/material_design_floating_action_menu_item1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:layout_margin="16dp"
    android:clickable="true"
    android:src="@mipmap/ic_launcher"
    fab:fab_size="normal"
    android:visibility="visible"/>

OUTPUT:

enter image description here

希望这会有所帮助〜


0
投票

我不确定这是不是一个好方法,但它确实有效。我将此行添加到dimens.xml中。

    <dimen tools:override="true"
    name="design_fab_image_size">56dp</dimen>
© www.soinside.com 2019 - 2024. All rights reserved.