Nir*_*ati 12 android android-progressbar android-alertdialog
我想改变具有黑色半透明背景的进度条的背景颜色,不透明度小于50%.我搜索了很多关于这个,但无法找到解决方案.我不知道我是否对,但它与进度条的mdecor属性有关.
以下是我使用它的代码.
pd = ProgressDialog.show(getActivity(), null, null,true);
pd.setContentView(R.layout.remove_border);
Run Code Online (Sandbox Code Playgroud)
删除边框布局的代码是:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:indeterminateDrawable="@drawable/my_progress_indeterminate" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
my_progress_indeterminate的代码是:
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/loadingiconblack"
android:pivotX="50%"
android:pivotY="50%" />
Run Code Online (Sandbox Code Playgroud)
以下是背景区域以红色圆圈标记的图像.我想用相同的不透明度将颜色更改为白色.

编辑:
感谢Sripathi和user3298272在这里结合两种解决方案的最终解决方案是我的最新答案:
pd = new Dialog(this, android.R.style.Theme_Black);
View view = LayoutInflater.from(this).inflate(R.layout.remove_border, null);
pd.requestWindowFeature(Window.FEATURE_NO_TITLE);
pd.getWindow().setBackgroundDrawableResource(R.color.transparent);
pd.setContentView(view);
pd.show();
Run Code Online (Sandbox Code Playgroud)
remove_border xml代码:这里android:gravity ="center"是我的线性布局代码中添加的.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"
android:gravity="center"
android:orientation="vertical" >
<ProgressBar
android:id="@+id/progressBar1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="@android:color/transparent"
android:indeterminateDrawable="@drawable/my_progress_indeterminate" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
颜色xml代码:
<resources>
<color name="transparent">#80FFFFFF</color>
</resources>
Run Code Online (Sandbox Code Playgroud)
在#80FFFFFF 80中,我从user3298272获取的不透明度值为50%.
Cha*_*dru 11
这是Hex颜色代码的透明色比.
100% - FF
95% - F2
90% - E6
85% - D9
80% - CC
75% - BF
70% - B3
65% - A6
60% - 99
55% - 8C
50% - 80
45% - 73
40% - 66
35% - 59
30% - 4D
25% - 40
20% - 33
15% - 26
10% - 1A
5% - 0D
0% - 00
只需在颜色代码前添加不透明度百分比.例如:黑色的颜色代码是#0000.如果我想要50%透明度的透明黑色意味着在#0000之前添加80(即#800000)
Sri*_*thi 10
您可以使用对话框而不是progressdialog,
dialogTransparent = new Dialog(this, android.R.style.Theme_Black);
View view = LayoutInflater.from(getActivity()).inflate(
R.layout.remove_border, null);
dialogTransparent.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialogTransparent.getWindow().setBackgroundDrawableResource(
R.color.transparent);
dialogTransparent.setContentView(view);
Run Code Online (Sandbox Code Playgroud)
更新:
Here the color transparent is #80FFFFFF
Run Code Online (Sandbox Code Playgroud)