我目前有一个个人资料页面,可让用户在Android中更改自己的图片。
加载新图像时,我想禁用活动中的所有输入操作(点击/滑动),并在加载进度条上显示半透明胶片。
不幸的是,我当前的实现并没有按预期工作 - 操作仍然传递给底层。
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.example.www.android_image_cropper_v2.ProfileActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<Button
android:id="@+id/choose_button"
android:text="Choose picture"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="@+id/remove_button"
android:text="Remove picture"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="@+id/blocking_film"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:background="#33000000">
<ProgressBar
android:layout_width="40dp"
android:layout_height="40dp" />
</LinearLayout>
</FrameLayout>
以下是活动的代码
package com.example.www.android_image_cropper_v2;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
public class ProfileActivity extends AppCompatActivity
{
public Button CHOOSE_BUTTON;
public Button REMOVE_BUTTON;
public LinearLayout BLOCKING_FILM;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_profile);
CHOOSE_BUTTON = (Button) findViewById(R.id.choose_button);
REMOVE_BUTTON = (Button) findViewById(R.id.remove_button);
BLOCKING_FILM = (LinearLayout) findViewById(R.id.blocking_film);
CHOOSE_BUTTON.setOnClickListener(choose_listener);
REMOVE_BUTTON.setOnClickListener(remove_listener);
}
public View.OnClickListener choose_listener = new View.OnClickListener()
{
@Override
public void onClick(View v)
{
BLOCKING_FILM.setVisibility(View.VISIBLE);
}
};
public View.OnClickListener remove_listener = new View.OnClickListener()
{
@Override
public void onClick(View v)
{
// pass
}
};
}
Blocking Film
陷阱所有UI操作? (全部,而不仅仅是点击)答案 0 :(得分:1)
在android:clickable="true"
。
blocking_film