浮动按钮未出现在kitkat中 [英] Floating action button doesn't appear in kitkat

查看:94
本文介绍了浮动按钮未出现在kitkat中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个单页面应用程序,其中的浮动操作按钮用于共享页面中的内容.它在android棒棒糖中完美运行,但是当我在kitkat上运行该应用程序时,它没有显示.由于唯一的交互式组件是FAB,因此用户只能凝视.我进行了一些搜索,发现FAB应该可以很好地在kitkat上运行,并且只有在涉及棒棒糖时才存在一些问题(例如填充).但是,它在棒棒糖中也很好用.对于棒棒糖之前的版本,是否需要将其更改为按钮?我的第一个问题在这里.任何帮助表示赞赏.谢谢.

I have created a single page app where the floating action button is used to share content from the page. It works flawlessly in android lollipop but when i ran the app on kitkat, it doesn't show. Since the only interactive component is the FAB, the user is left with nothing to do but stare. I ran some search and found that the FAB should work perfectly on kitkat and that there are some issues only when it comes to lollipop(like padding). But, it works just fine in lollipop. Do I have to change it to a button for versions older than lollipop? My first question here. Any help is appreciated. Thanks.

activity_main.xml

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>

推荐答案

我也有同样的问题,可能是由于材料设计,因为在kitkat之后引入了材料设计,因此在某些选项卡或布局上存在一些问题,请尝试一下它对我有用,也许对你有用.

I also have the same problem may be it is due to material design as material design introduced after kitkat so there be some problem on some tabs or layouts but try this it works for me maybe works for you..

<?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>

这篇关于浮动按钮未出现在kitkat中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆