2017-06-02 17 views
0

我有兩個小的Fab彼此相鄰如下:不一致FloatingActionButton填充與useCompatPadding上API 21或更高

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

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/zoom_in_fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     app:srcCompat="@drawable/ic_zoom_in" 
     app:fabSize="mini" 
     app:useCompatPadding="true"/> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/zoom_out_fab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     app:srcCompat="@drawable/ic_zoom_out" 
     app:fabSize="mini" 
     app:useCompatPadding="true"/> 

</LinearLayout> 

這看起來在大多數情況下細,除非按鈕中的一個被禁用(使用fab.setEnabled(false)之前佈局繪製。 Then it looks like this

縮小FAB似乎在左側填充較少,雖然在此特定圖像中看不到它,但頂部填充較少。這隻發生在我使用app:useCompatPadding="true"時,而不是像android:layout_margin="12dp"(在API 21之前和之後看起來不一致)之類的東西。

這隻發生在API 21或更高版本上。它在API 17-19上看起來很完美。

我的假設是,在支持庫(我使用25.3.1)中存在一個錯誤,其中在繪製佈局之前使用FAB的高程來設置邊距,但它不考慮其中的情況如果FAB被禁用,FAB不會提升。

有沒有其他人遇到過這個問題,或者有沒有解決方法?乾杯。

回答