2016-11-28 111 views
1

screenshot of fab buttons in xml我正在使用'com.github.clans:fab:1.6.4'库来显示fab按钮,它们工作正常,但是当我尝试更改按钮图像时那么图像看起来非常小,fab工厂按钮的图像根本没有改变。 有人可以告诉我如何解决这个问题?如何在android中更改fab菜单按钮图像

这里是XML代码:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
xmlns:fab="http://schemas.android.com/apk/res-auto" 
android:orientation="vertical"> 

<HorizontalScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true" 
    android:scrollbars="none" > 
    <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" 
     android:layout_weight="1" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true"> 

     <TableLayout 
      android:layout_marginTop="10dp" 
      android:id="@+id/tabla_cuerpo" 
      android:layout_width="match_parent" 
      android:layout_height="362dp"> 

      <TableRow 
       android:id="@+id/tableRow1" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:background="#BCBCBC"> 

       <TextView 
        android:id="@+id/textView1a" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="#BCBCBC"    android:padding="5dp" 
        android:text="Case#" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 

       <TextView 
        android:id="@+id/textView1b" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="#BCBCBC"    android:padding="5dp" 
        android:text="Client" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 

       <TextView 
        android:id="@+id/textView1c" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="#BCBCBC"    android:padding="5dp" 
        android:text="Case Amount" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
       <TextView 
        android:id="@+id/textView1d" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="#BCBCBC"    android:padding="5dp" 
        android:text="Received" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
       <TextView 
        android:id="@+id/textView1e" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="#BCBCBC"    android:padding="5dp" 
        android:text="Reminder" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
       <TextView 
        android:id="@+id/textView1f" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="#BCBCBC"    android:padding="5dp" 
        android:text="Remarks" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 

      </TableRow> 

      <TableRow 
       android:id="@+id/tableRow2" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

        <TextView 

       android:id="@+id/textView2a" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:background="@drawable/cellshape" 
       android:padding="5dp" 
       android:text="Case#" 
       android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 

       <TextView 
        android:id="@+id/textView2b" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Client" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 

       <TextView 
        android:id="@+id/textView2c" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Case Amount" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
       <TextView 
        android:id="@+id/textView2d" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Received" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
       <TextView 
        android:id="@+id/textView2e" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Reminder" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
       <TextView 
        android:id="@+id/textView2f" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Remarks" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
      </TableRow> 
      <TableRow 
       android:id="@+id/tableRow3" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <TextView 

        android:id="@+id/textView3a" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Case#" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 

       <TextView 
        android:id="@+id/textView3b" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Client" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 

       <TextView 
        android:id="@+id/textView3c" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Case Amount" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
       <TextView 
        android:id="@+id/textView3d" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Received" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
       <TextView 
        android:id="@+id/textView3e" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Reminder" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
       <TextView 
        android:id="@+id/textView3f" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:background="@drawable/cellshape" 
        android:padding="5dp" 
        android:text="Remarks" 
        android:textAppearance="?android:attr/textAppearanceMedium"></TextView> 
      </TableRow> 

     </TableLayout> 

    </LinearLayout> 
</HorizontalScrollView> 

<FrameLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <com.github.clans.fab.FloatingActionMenu 
     android:id="@+id/fab_menu" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentRight="true" 
     android:paddingBottom="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     fab:menu_backgroundColor="#ccffffff" 
     fab:fab_colorNormal="#DA4336" 
     fab:fab_colorPressed="#E75043" 
     fab:fab_colorRipple="#99FFFFFF" 
     fab:fab_showShadow="true" 
     fab:menu_labels_colorNormal="#333333" 
     fab:menu_labels_colorPressed="#444444" 
     fab:menu_labels_colorRipple="#66FFFFFF" 
     fab:menu_labels_showShadow="true" 
     fab:menu_labels_maxLines="-1" 
     fab:menu_labels_position="left" 
     fab:menu_openDirection="up" 
     fab:fab_shadowColor="#66000000" 
     fab:menu_labels_ellipsize="end" 
     fab:menu_labels_singleLine="true"> 

     <com.github.clans.fab.FloatingActionButton 
      android:id="@+id/fab2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/add_payment_btn" 
      fab:fab_label="ADD PAYMENT" 
      fab:fab_size="mini" /> 

     <com.github.clans.fab.FloatingActionButton 
      android:id="@+id/fab3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@drawable/editcasesicon" 
      fab:fab_label="EDIT PAYMENT" 
      fab:fab_size="mini" /> 

    </com.github.clans.fab.FloatingActionMenu> 
</FrameLayout> 

<ImageButton 
    android:id="@+id/imageButton1" 
    android:layout_width="60dp" 
    android:layout_height="60dp" 
    android:background="@drawable/delete" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentLeft="true" 
    android:layout_marginLeft="30dp" 
    android:layout_marginBottom="21dp" 
    /> 
</RelativeLayout> 
+0

如果可能的话发布你的xml代码。 –

+0

@sathishgadde请检查我更新的问题 – Annie

回答

0

我只是使用了相同的库.SET您绘制的图像大小为24dp高度和24dp width.am张贴我的示例代码屏幕shot.i希望能有用的您。

您不要同时使用两个和 只使用任何一个FloatingActionButton。否则在控制声明[FloatingActionButton]期间引发错误。 enter image description here enter image description here

如果你想chnage FloatingActionMenu图像,然后你可以从你的库项目,开放FloatingActionMenu.class并从该文件中的行更改图像绘制没有。 161改变你的图像可以绘制任何你想要的。

+0

不,您的答案不正确,因为这不起作用 – Annie

+0

对不起,您说“图像看起来非常小,fab工厂按钮的图像根本没有改变”。你的代码是正确的。但你只是改变晶圆厂菜单绘制[图像]大小更改为身高:24dp和重量:24dp –

+0

并告诉我你想改变哪个图像。 –