我創建了一個活動,其中包含一個AsyncTask以從互聯網獲取一些數據。我在佈局中添加了一個進度條,用戶無法與edittext交互,直到數據加載完成。 在內容加載過程中,我會使當前佈局較暗,以便用戶瞭解它在加載期間未處於活動狀態的佈局。 是否可以添加一個覆蓋當前包含進度條小部件的較暗佈局?如何在內容加載期間將較暗的佈局與當前佈局重疊?
這裏是我的佈局:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/home"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:contentDescription="@string/mylogo"
android:src="@drawable/myapp_logo" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >
<TextView
android:id="@+id/textMethod"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="@string/method"
android:textColor="@color/black" />
<Spinner
android:id="@+id/spinner1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_below="@id/textSpinner"
android:textSize="18sp"
android:inputType="text"
android:textColor="@color/black" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="20dp" >
<TextView
android:id="@+id/textMethod2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="@string/method2"
android:textColor="@color/black" />
<EditText
android:id="@+id/editMethod2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_below="@id/textMethod2"
android:textSize="18sp"
android:inputType="text"
android:textColor="@color/black" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginTop="20dp" >
<TextView
android:id="@+id/textTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:text="@string/total"
android:textColor="@color/black" />
<EditText
android:id="@+id/editTotal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/textTotal"
android:textSize="18sp"
android:inputType="text"
android:textColor="@color/black" />
</RelativeLayout>
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:background="@drawable/yellow_button_event"
android:onClick="send"
android:text="@string/send" />
</LinearLayout>
</ScrollView>
埃姆...什麼都沒有用你的編輯更改... – smartmouse 2015-02-23 17:18:27