java - 在加载动画期间使背景元素变暗/变暗 - Android

标签 java android xml android-view android-progressbar

在单击登录按钮后出现的进度条微调器中,我希望当微调器在屏幕上可见时微调器后面的元素变暗或变暗。我的布局文件目前看起来像这样:

<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 channel 的背景颜色应用于 relativelayout。 例如#99000000

关于java - 在加载动画期间使背景元素变暗/变暗 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26506881/

相关文章:

c# - 使用 c# Xdocument 类添加子节点

java - Hibernate with mysql 覆盖pk

java - 没有平方根的归一化空间 vector

java - Android 框架布局并排

android - 在 picasso 中加载图像后无法隐藏进度条?

android - 自动播放YouTube视频-iframe

java - XML 字符串资源与 Java 常量字符串?

java - 冰雹序列,递归,缺少 1 个案例

javascript - 使用 Karma 运行 javascript 单元测试时,Gradle exec 任务挂起

python - OpenERP : How to display fields of two objects within the same view?