简体   繁体   English

浮动动作按钮已隐藏

[英]Floating action button hidden

I'm developing an Android application with a Floating Action Button. 我正在开发带有浮动操作按钮的Android应用程序。

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. 这个按钮通常显示在我的android版本(5)中,但是在android 4.3中,FAB是隐藏的,您可以单击它,即使它起作用也不会显示。

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.. 我不知道为什么它隐藏在某些设备中并在其他设备中显示。

As @Alex Chengalan suggested, I post the answer hoping someone else might need it :) 正如@Alex Chengalan所建议的那样,我发布答案希望其他人可能需要它:)

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. 这篇文章中,他找到了解释,因为FAB已添加了棒棒糖,因此以前的Android版本无法使用它。

So you will have a working FAB but hidden and not shown at all. 因此,您将拥有一个可用的FAB,但已隐藏并且完全没有显示。 (It will work if you click it, but you will not see it). (如果单击它,它将起作用,但看不到它)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM