【发布时间】:2016-05-22 04:03:39
【问题描述】:
我正在开发一个主要使用listview 的Android 应用程序。但是我在使用Floating Action Button 和Long ListView 时遇到了问题。我的问题如下。
当列表视图只有几个项目时。可以看到Floating item。
这是截图:
正如你在上面看到的,Floating Action Button 仍然可以看到。但是当ListView 有这么多项目并且在屏幕上变得过多时,Floating Action Button 就看不到了。
这是Long Listview的截图
第二个屏幕截图,不能再是scrolled down了。
我想要实现的是,我希望浮动底部始终位于Listview上方的屏幕右下角。比如HTML和CSS中的固定位置。
无论Listview 有多高,我都希望Floating Action Button 一直在这里
这是我的布局文件
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:dividerHeight="@dimen/list_item_divider_height"
android:padding="@dimen/list_padding"
android:divider="@color/whitesmoke"
android:id="@+id/listview_podcast_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"></ListView>
<TextView
android:textSize="17dp"
android:textStyle="bold"
android:textColor="@color/black"
android:textAlignment="center"
android:id="@+id/tf_no_records"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.design.widget.FloatingActionButton
android:id="@+id/stop_podcast_button"
android:background="@color/colorPrimary"
android:src="@android:drawable/ic_dialog_email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"/>
</LinearLayout>
如何修复我的代码以实现它?
【问题讨论】:
标签: android listview floating-action-button