Reputation: 6065
I currently have a profile page that lets users change their picture in Android.
When loading the new image, I want to disable all input actions (clicks/swipes) in the activity and display a semi-transparent film over it with a loading progress bar.
Unfortunately, my current implementation does not work as intended - actions are still getting passed to the under layers.
<?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>
And here is the code for the activity
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
traps all UI actions? (ALL, not just CLICK)Upvotes: 0
Views: 194