I am making an android application containing a listview which updates every 30 seconds. If there is new data, I want a button to appear where I can update the feed, similar to the facebook app. How can I accomplish this? Is there a way to overlay a button on top of a listview that appears at the top of the screen when not scrolling in the listview?
Here is my listview xml:
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/swipe_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:layout_height="wrap_content"
android:layout_below="@id/header"
android:divider="@android:color/transparent"
android:dividerHeight="10dp"
/>
</LinearLayout>
<Button
android:id="@+id/update_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:text="Button" />
Try using the
setOnScrollListener
and implement theonScrollStateChanged
.Overlaying of views can be seen here.