2015-10-07 105 views
1

我想减少FAB利润pre-Lollipop设备,但无论我做什么 - 没有任何变化。我创建了两个FAB,其中一个在right|end|bottom之内,其他都是以前的。那16dp页边距使得两个FAB之间的距离为32dp,这对我来说太大了。如果使用bottop_padding向下按钮的可点击区域与第二个按钮重叠。也许,有人有同样的问题?请帮帮我!Android支持设计浮动按钮

here is picture of how it looks like

<android.support.design.widget.CoordinatorLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/first" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/directions" 
      app:backgroundTint="@android:color/holo_blue_light" 
      app:elevation="6dp" 
      app:pressedTranslationZ="12dp" 
      android:layout_above="@+id/uer_position" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" /> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/second" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/my_location" 
      app:backgroundTint="@android:color/white" 
      app:elevation="6dp" 
      app:pressedTranslationZ="12dp" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" /> 

     </RelativeLayout> 
+0

你能发布你的xml文件吗? –

+0

@MarianoZorrilla,完成 – Near1999

+1

*这16dp的利润*哪?他们在哪里定义? –

回答

0

在预棒棒糖,边距自动添加到FAB秒。创建一个名为values-v21一个新的文件夹,并创建一个xml文件名为dimes.xml,并添加以下行

<dimen name="btn_fab_margins">16dp</dimen> 

然后转到您的dimens.xmlvalues文件夹,并添加以下

<dimen name="btn_fab_margins">0dp</dimen> 

现在在布局添加继FAB之后

android:layout_margin="@dimen/btn_fab_margins" 

问题即将解决。与前棒棒糖一样,它将采用0dp保证金,而棒棒糖则采用16dp保证金。

+0

我这样做,但使用样式。预棒棒糖设备上没有任何更改 – Near1999

+0

是否确定为两个值文件添加了尺寸? –

+0

将margin设置为'0'不会从屏幕截图删除边距, – Near1999