FAB 图标不填充按钮
FAB Icon Doesn't Fill Button
我的布局如何导致浮动操作 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>
将属性 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"/>
输出:
希望对你有所帮助~
您使用的图标有误。您的晶圆厂运行正常。看看 material guidelines.
您应该使用 this 图标来代替该图标,以实现与 Google 日历应用程序中类似的 fab 设计。
我不确定这是否是个好方法,但它确实有效。我将此行添加到 dimens.xml.
<dimen tools:override="true"
name="design_fab_image_size">56dp</dimen>
我的布局如何导致浮动操作 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>
将属性 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"/>
输出:
希望对你有所帮助~
您使用的图标有误。您的晶圆厂运行正常。看看 material guidelines.
您应该使用 this 图标来代替该图标,以实现与 Google 日历应用程序中类似的 fab 设计。
我不确定这是否是个好方法,但它确实有效。我将此行添加到 dimens.xml.
<dimen tools:override="true"
name="design_fab_image_size">56dp</dimen>