Al Phaba
Al Phaba

Reputation: 6755

How to center a progress icon in a listview so that it is viisble at the end of the list

I have added a progress icon in my listview, so during the processing time the loading icon will be displayed. This works fine but the icon will be shown in the first item. So if you scroll down the list and press the resend button, then the progress icon is not visible. Is there a way to center the icon on my complete list not only on the first item area?

Here is my layout

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
    android:id="@+id/pen_transfer_job_id_label"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:text="ID" />

<TextView
    android:id="@+id/pen_transfer_job_id"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/pen_transfer_job_id_label"
    />

<TextView
    android:id="@+id/pen_transfer_job_created_label"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_below="@id/pen_transfer_job_id_label"
    android:text="CREATED" />

<TextView
    android:id="@+id/pen_transfer_job_created"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/pen_transfer_job_created_label"
    android:layout_below="@id/pen_transfer_job_id"
    android:text="" />

<TextView
    android:id="@+id/pen_transfer_job_size_label"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:text="Bytes"
    android:layout_below="@id/pen_transfer_job_created_label"
    />

<TextView
    android:id="@+id/pen_transfer_job_size"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/pen_transfer_job_size_label"
    android:layout_below="@id/pen_transfer_job_created"
    android:text="" />

<TextView
    android:id="@+id/pen_transfer_job_retries_label"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_below="@id/pen_transfer_job_size_label"
    android:text="Retries" />


<TextView
    android:id="@+id/pen_transfer_job_retries"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_toRightOf="@id/pen_transfer_job_retries_label"
    android:layout_below="@id/pen_transfer_job_size"
    android:text="" />


<TextView
    android:id="@+id/pen_transfer_job_success_label"
    android:layout_width="100dp"
    android:layout_height="wrap_content"
    android:layout_below="@id/pen_transfer_job_retries_label"
    android:text="Success" />


<TextView
    android:id="@+id/pen_transfer_job_success"
    android:layout_width="wrap_content"
    android:layout_toRightOf="@id/pen_transfer_job_success_label"
    android:layout_below="@id/pen_transfer_job_retries"
    android:layout_height="wrap_content" />


<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_below="@id/pen_transfer_job_success_label"
    android:layout_height="wrap_content"

    >

    <Button
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:id="@+id/pen_transfer_delete_button"
        android:background="@drawable/trash_action"
        android:onClick="deleteJobAction"
        android:layout_alignParentLeft="true"
        />

    <ImageButton
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:text="Success Image"
        android:visibility="gone"
        android:id="@+id/pen_transfer_job_success_button"
        android:clickable="false"

        android:background="@drawable/success_action"
        android:layout_centerHorizontal="true"
        />
    <Button
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:id="@+id/pen_transfer_resend_button"
        android:background="@drawable/resend_action"
        android:onClick="resendDataAction"
        android:layout_alignParentRight="true"

         />
</RelativeLayout>
<ProgressBar
    android:id="@+id/resend_progress"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:indeterminate="true"
    android:visibility="invisible"
    android:layout_centerVertical="true"
    android:layout_centerHorizontal="true" />
</RelativeLayout>

Upvotes: 0

Views: 119

Answers (1)

Devraj
Devraj

Reputation: 1531

I think you have placed the ProgressBar in your second xml file. Place ProgressBar in your first xml file like this..

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<ListView
    android:id="@+id/listView1"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</ListView>

<ProgressBar
    android:id="@+id/progressBar1"
    style="?android:attr/progressBarStyleLarge"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:visibility="gone" />

<TextView
    android:id="@+id/emptyText"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="No data available"
    android:visibility="gone" />

Upvotes: 2

Related Questions