【发布时间】:2015-02-23 16:59:27
【问题描述】:
我创建了一个包含 AsyncTask 的活动以从 Internet 获取一些数据。我在布局中添加了一个进度条,因此用户在数据加载完成之前无法与 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>
【问题讨论】:
标签: android xml layout progress-bar overlap