-1

I want to create a layout with below features: I have a LinearLayout with TextView and Progressbar for showing progress UI when activity should to work network task. I mean this layout sometimes is visible and sometimes is gone.

I want a layout in ScrollView and a button in below page below in layout. I write below code. and button and scrollview shows good but when i set LinearLayout for progressBar to visible, layout shows bottom button. I don't want to shows any views when showing progressbar. How can i correct below code for solve this problem. Thanks for advises :)

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card_view="http://schemas.android.com/apk/res-atuo"
    xmlns:app="http://schemas.android.com/apk/res/com.kit.itil.sdcartable"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@+id/TaskDetailActivity_btn_report"
        android:orientation="vertical" >

        <RelativeLayout
            android:id="@+id/RelativeLayoutPb_TaskDetailActivity"
            android:layout_width="match_parent"
            android:layout_height="match_parent"

            android:visibility="gone" >

            <com.kit.helper.CustomTextView
                android:id="@+id/progressText_TaskDetailActivity"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:layout_marginTop="20dip"
                android:gravity="center"
                android:textColor="@color/gray_text"
                android:textSize="20sp"
                android:textStyle="bold" />

            <ProgressBar
                android:id="@+id/progressBar_TaskDetailActivity"
                style="?android:attr/progressBarStyleHorizontal"
                android:layout_width="70dip"
                android:layout_height="70dip"
                android:layout_centerInParent="true"
                android:indeterminate="true"
                android:indeterminateBehavior="cycle"
                android:indeterminateDrawable="@drawable/circular_progress" />
        </RelativeLayout>

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical" >'

        //...some layout is here...
            </LinearLayout>
        </ScrollView>
    </LinearLayout>

    <LinearLayout
        android:id="@id/TaskDetailActivity_btn_report"
        android:layout_width="match_parent"
        android:layout_height="55dip"
        android:layout_alignParentBottom="true"
        android:background="@color/blue"
        android:gravity="center"
        android:orientation="vertical" >

        <com.kit.helper.CustomTextView
            android:id="@+id/TaskDetailActivity_TextView_report"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:gravity="right"
            android:text="@string/TaskDetailActivity_TextView_reportBtn"
            android:textColor="@android:color/white"
            android:textSize="20sp"
            android:textStyle="bold" />
    </LinearLayout>

</RelativeLayout>
TestAndroid
  • 61
  • 1
  • 3

1 Answers1

0

While doing network task AsyncTask should be used so that it doesn't start on main UI thread If AsyncTask is used properly your problem will get resolved.

Please refer to

Community
  • 1
  • 1
bond007
  • 2,434
  • 1
  • 17
  • 17