Android 浮动操作按钮没有';不要出现在kitkat中

Android 浮动操作按钮没有';不要出现在kitkat中,android,xml,android-5.0-lollipop,android-4.4-kitkat,floating-action-button,Android,Xml,Android 5.0 Lollipop,Android 4.4 Kitkat,Floating Action Button,我创建了一个单页应用程序,其中浮动操作按钮用于共享页面内容。它在安卓棒棒糖中完美地工作,但当我在kitkat上运行应用程序时,它没有显示出来。由于唯一的交互组件是晶圆厂,用户除了盯着晶圆厂外别无选择。我进行了一些搜索,发现晶圆厂应该在kitkat上工作得很好,而且只有在棒棒糖(如填充物)上才会出现一些问题。但是,它在棒棒糖中效果很好。对于比棒棒糖更老的版本,我必须将其更改为按钮吗?我的第一个问题。感谢您的帮助。谢谢 activity_main.xml <?xml version="1.0"

我创建了一个单页应用程序,其中浮动操作按钮用于共享页面内容。它在安卓棒棒糖中完美地工作,但当我在kitkat上运行应用程序时,它没有显示出来。由于唯一的交互组件是晶圆厂,用户除了盯着晶圆厂外别无选择。我进行了一些搜索,发现晶圆厂应该在kitkat上工作得很好,而且只有在棒棒糖(如填充物)上才会出现一些问题。但是,它在棒棒糖中效果很好。对于比棒棒糖更老的版本,我必须将其更改为按钮吗?我的第一个问题。感谢您的帮助。谢谢

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.ataraxianstudios.decksharer.MainActivity"
    >


    <android.support.design.widget.FloatingActionButton
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_margin="@dimen/fab_margin"
        android:src="@drawable/share1"/>

<ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#016cb4">
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:id="@+id/llMain"
        >
<Spinner
        android:id="@+id/osversions"
        android:layout_width="220dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="10dp"
        />
    <ImageView
        android:layout_width="60dp"
        android:layout_height="80dp"
        android:id="@+id/selectedImage"
        />

</LinearLayout>
    </ScrollView>
</android.support.design.widget.CoordinatorLayout>

您正在使用设计支持库吗? 这是一个例子:

<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@android:drawable/ic_input_add" />

希望它能帮助你

我也有同样的问题,可能是因为kitkat之后引入的材质设计导致的,所以在某些选项卡或布局上存在一些问题,但试试这个,它对我有效,可能对你有效

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout     
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.ataraxianstudios.decksharer.MainActivity"
>



//Replace your fab from here

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#016cb4">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    android:id="@+id/llMain"
    >
<Spinner
    android:id="@+id/osversions"
    android:layout_width="220dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp"
    />
<ImageView
    android:layout_width="60dp"
    android:layout_height="80dp"
    android:id="@+id/selectedImage"
    />

</LinearLayout>
</ScrollView>


//to here:
<android.support.design.widget.FloatingActionButton
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom|end"
    android:layout_margin="@dimen/fab_margin"
    android:src="@drawable/share1"/>
</android.support.design.widget.CoordinatorLayout>

//从这里更换晶圆厂
//到这里:

使用bringToFront为您浮动操作按钮

fab = view.findViewById(R.id.fab_hours);
fab.bringToFront();

看看,我正是这么做的。但是,当我在运行4.4的设备上测试它时,它不会显示。你能显示你在布局中使用的代码吗?我读了你分享的帖子。这是否意味着我必须检查api版本,然后使用浮动操作按钮?因此,对于kitkat,我可能会使用按钮而不是FAB来实现相同的结果?请尝试此材料设计教程。。。。。。。。。。。。。
fab = view.findViewById(R.id.fab_hours);
fab.bringToFront();