加载动画期间变暗/昏暗的背景元素 - Android
问题描述:
单击登录按钮后会出现一个进度条微调控制器,我希望微调器后面的元素变暗或变暗,而微调器在屏幕上可见。我的布局文件看起来像这样目前:加载动画期间变暗/昏暗的背景元素 - Android
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="apps.kusasa.biz.MainActivity" >
<EditText
android:id="@+id/EditText01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/editText2"
android:layout_alignLeft="@+id/editText2"
android:layout_alignRight="@+id/editText2"
android:ems="10"
android:hint="Username"
android:inputType="text" />
<EditText
android:id="@+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/loginBtn"
android:layout_centerHorizontal="true"
android:ems="10"
android:hint="Password"
android:inputType="textPassword" >
<requestFocus />
</EditText>
<Button
android:id="@+id/loginBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/EditText01"
android:layout_alignParentBottom="true"
android:layout_alignRight="@+id/EditText01"
android:layout_marginBottom="67dp"
android:text="Login" />
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/EditText01"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/pics_logo" />
<ProgressBar
android:id="@+id/progressBar1"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/editText2"
android:layout_centerHorizontal="true"
android:layout_marginBottom="77dp" />
</RelativeLayout>
我的按钮单击方法:
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.loginBtn:
spinner.setVisibility(View.VISIBLE);
// etc
}
}
如何实现这一目标?谢谢!
答
当您的微调器与您想要调暗的元素布局相同时,这将会很困难。我会将微调器移动到单独的(父级)布局,然后将Alpha背景颜色应用于相关布局。 例如#99000000
你会使用什么类型的布局? – 2014-10-22 12:34:27
怎么样FrameLayout,然后你可以堆叠元素 – Carsten 2014-10-22 12:54:06
这条路线提出了大量的问题,如framelayout不填满屏幕,进度条微调不再停留在布局的中间,以及其他需要更多解决方法的事情。 – 2014-10-22 14:46:56