2015-03-03 95 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