我创建了一个活动,其中包含一个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