我想在FloatingActionButton上面添加一个TextView,我使用FrameLayout作为TextView和FloatingActionButton的父布局,这里是我的示例代码:
- <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之下,就像这样
我想要这样显示:
我很穷,有人可以帮我吗?
解决方法
您只需要将height属性添加到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"/>
- </FrameLayout>