如何在Android中增加一个FloatingActionButton上面一个TextView [英] How to add a TextView above a FloatingActionButton in Android

查看:5978
本文介绍了如何在Android中增加一个FloatingActionButton上面一个TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想补充一个FloatingActionButton上面一个TextView,我用的FrameLayout作为TextView的和FloatingActionButton的父布局,这里是我的样本code:

I want to add a TextView above a FloatingActionButton, I use the FrameLayout as the parent layout of the TextView and FloatingActionButton, here is my sample code:

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <android.support.design.widget.FloatingActionButton
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:id="@+id/fab"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:backgroundTint="#00fff0"
        app:borderWidth="0dp"
        android:elevation="0dp"
        app:fabSize="normal" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="#000000"
        android:text="above"/>

</FrameLayout>

但它是无用的,TextView的是FloatingActionButton下方,这样

和我想它显示是这样的:

and I want it show like this:

我穷这一点,任何人都可以帮我吗?

I am poor for this, can anyone help me?

推荐答案

您只需要高程属性为TextView的

you just need to elevation attribute to the textview

<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<android.support.design.widget.FloatingActionButton
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/fab"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:backgroundTint="#00fff0"
    app:borderWidth="0dp"
    android:elevation="0dp"
    app:fabSize="normal" />

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="#000000"
    android:text="above"
    android:elevation="7dp"/>

这篇关于如何在Android中增加一个FloatingActionButton上面一个TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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