任何人都知道如何在 andorid 中运行进度条轮时设置背景模糊。我希望当圆形轮进度条运行且背景中没有交互时,屏幕看起来模糊。
最佳答案
我正在使用此代码,因为我的要求与您相同,这也最适合您的要求。
您可以在基本 Activity 类中编写此代码并将其用作您的要求。
ViewGroup progressView;
protected boolean isProgressShowing = false;
public void showProgressingView() {
if (!isProgressShowing) {
isProgressShowing = true;
progressView = (ViewGroup) getLayoutInflater().inflate(R.layout.progressbar_layout, null);
View v = this.findViewById(android.R.id.content).getRootView();
ViewGroup viewGroup = (ViewGroup) v;
viewGroup.addView(progressView);
}
}
public void hideProgressingView() {
View v = this.findViewById(android.R.id.content).getRootView();
ViewGroup viewGroup = (ViewGroup) v;
viewGroup.removeView(progressView);
isProgressShowing = false;
}
这里progressbar_layout.xml
是
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#BA000000">
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerInParent="true"
/>
</RelativeLayout>
- 这是一种简单而巧妙的方法。
- 您可以以任何方式、任何颜色、任何样式自定义您的
progressbar_layout
。 - 摆脱默认的 Android 进度条
关于android - 在android中运行进度条时设置背景屏幕模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26992869/