2016-11-28 109 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

並告訴我你想改變哪個圖像。 –