2015-03-03 41 views
2

我在我的項目中使用此https://github.com/makovkastar/FloatingActionButton庫FloatingActionButtons。在一些較小的設備上,例如Acer Liquid Z4(Android版本4.2.2,屏幕480x800)或Genymotion Galaxy S2圖像(Android版本4.1.1,屏幕480x800),FAB周圍有一個黑盒子:FloatingActionButton黑盒子

enter image description here

我試圖縮小下來,從我的主題使它看起來像這樣刪除任何特殊的東西:

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 
    <!-- Customize your theme here. --> 

</style> 

,並把按鈕放在最簡單的佈局:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
       xmlns:tools="http://schemas.android.com/tools" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:paddingLeft="@dimen/activity_horizontal_margin" 
       android:paddingRight="@dimen/activity_horizontal_margin" 
       android:paddingTop="@dimen/activity_vertical_margin" 
       android:paddingBottom="@dimen/activity_vertical_margin" 
       tools:context="de.immowelt.android.immobiliensuche.ui.FabTestActivity"> 


    <com.melnykov.fab.FloatingActionButton 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"/> 

</RelativeLayout> 

但箱子仍然存在。另一方面,我試圖用一個新項目重新創建效果,但無法完成。

使用mini尺寸版本或禁用陰影時,該框消失。

關於我的問題是什麼的任何想法?

PS:我試圖清理項目;)

回答

2

的問題是,FloatingActionButton類可以使用的陰影稱爲shadow.9.png繪製的。我的繪圖中還有一個shadow.9.png,圖書館班明顯地拿起了錯誤的(我的)。 重命名我的drawable解決了這個問題。

2

我使用這個庫但後來決定做我自己,其設置爲背景的ImageButton的什麼的。我使用了一個textview,因爲我需要的只是一個+。它在我的應用程序中看起來很不錯。

<?xml version="1.0" encoding="utf-8"?> 

<layer-list xmlns:android="http://schemas.android.com/apk/res/android"> 


    <!-- Drop Shadow Stack --> 

    <item> 

        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > 

            <padding android:right="1dp" android:bottom="1dp" /> 

            <solid android:color="#00262626" /> 

        </shape> 

    </item> 

    <item> 

        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > 

            <padding android:right="1dp" android:bottom="1dp" /> 

            <solid android:color="#0D262626" /> 

        </shape> 

    </item> 

    <item> 

        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > 

            <padding android:right="1dp" android:bottom="1dp" /> 

            <solid android:color="#26262626" /> 

        </shape> 

    </item> 


    <!-- Background --> 

    <item> 

        <shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval" > 

            <solid android:color="#448AFF"/> 

        </shape> 

    </item> 

</layer-list> 
+0

這很好,但我需要該庫的其他方法。 – FWeigl 2015-03-03 14:04:45

+0

夠公平的。我這樣做也是因爲大多數動作按鈕庫的影子不太正確。你使用的是什麼功能? – 2015-03-03 14:07:18

+0

將按鈕附加到例如ScrollView。我知道這可以用自己的代碼來解決,但這是我真正不想做的事情。 – FWeigl 2015-03-03 14:38:37