0

I'm developing an Android application with a Floating Action Button.

This button is normally shown in my android version(5), but in android 4.3 The FAB is hidden, you can click it but it is not showing even if it works.

this is my code:

<View
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:focusable="true"
    android:focusableInTouchMode="true"/>

<LinearLayout
    android:id="@+id/llTop"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_margin="@dimen/textPaddings"
    android:background="@color/headerColor"
    android:orientation="horizontal"
    android:weightSum="5">

    <TextView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="3"
        android:padding="@dimen/textPaddings"
        android:text="Saldo disponibile:"
        android:textColor="@color/white"
        android:textSize="20sp"
        android:textStyle="italic" />

    <TextView
        android:id="@+id/tvBudget"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:gravity="end"
        android:padding="@dimen/textPaddings"
        android:text=""
        android:textColor="@color/white"
        android:textSize="20sp"
        android:textStyle="bold" />

</LinearLayout>

<ListView
    android:id="@+id/lvTransactions"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_above="@+id/llBot"
    android:layout_below="@+id/llTop"
    android:layout_marginLeft="@dimen/textPaddings"
    android:layout_marginRight="@dimen/textPaddings">

</ListView>


<android.support.design.widget.FloatingActionButton
    android:id="@+id/btnAdd"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignTop="@+id/llBot"
    android:layout_marginTop="-15dp"
    android:clickable="true"
    android:src="@drawable/piu"
    app:fabSize="mini"
    app:layout_anchor="@id/llBot" />

<LinearLayout
    android:id="@+id/llBot"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_margin="@dimen/textPaddings"
    android:background="@color/headerColor"
    android:orientation="vertical">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2">

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/textPaddings"
            android:layout_weight="1"
            android:text="Descrizione:"
            android:textColor="@color/whiteOpaque"
            android:textSize="15sp"
            android:textStyle="italic" />

        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/textPaddings"
            android:layout_weight="1"
            android:text="Importo:"
            android:textColor="@color/whiteOpaque"
            android:textSize="15sp"
            android:textStyle="italic" />
        <!--<Button-->
            <!--android:layout_width="0dp"-->
            <!--android:layout_height="50dp"-->
            <!--android:layout_weight="1"-->
            <!--android:text="+"-->
            <!--android:textSize="25sp"-->
            <!--android:onClick="add"-->
            <!--/>-->
    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2">

        <EditText
            android:id="@+id/etDescr"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/textPaddings"
            android:layout_weight="1"
            android:background="@drawable/edittext_rounded"
            android:hint="descrizione spesa"
            android:inputType="textCapSentences"
            android:paddingEnd="10dp"
            android:paddingStart="10dp" />

        <EditText
            android:id="@+id/etImporto"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_margin="@dimen/textPaddings"
            android:layout_weight="1"
            android:background="@drawable/edittext_rounded"
            android:drawableEnd="@drawable/euro"
            android:hint="importo"
            android:inputType="numberDecimal"
            android:paddingEnd="10dp"
            android:paddingStart="10dp" />
    </LinearLayout>

    <RadioGroup
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="2"

        >

        <RadioButton
            android:id="@+id/rbEntrata"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:text="Entrata"
            android:textColor="@color/white"
            android:textSize="15sp" />

        <RadioButton
            android:id="@+id/rbUscita"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:checked="true"
            android:text="Uscita"
            android:textColor="@color/white"
            android:textSize="15sp" />
    </RadioGroup>
</LinearLayout>

I can't figure out why it's hidden in some devices and showing in others..

Pier Giorgio Misley
  • 5,305
  • 4
  • 27
  • 66

1 Answers1

1

As @Alex Chengalan suggested, I post the answer hoping someone else might need it :)

from this post he found the explaination, since the FAB has been added with lollipop, previous versions of Android are not enabled to use it.

So you will have a working FAB but hidden and not shown at all. (It will work if you click it, but you will not see it).

Pier Giorgio Misley
  • 5,305
  • 4
  • 27
  • 66