I want to change background color of the progressbar having black translucent background with opacity less than 50%. I searched a lot about this but not able to find solution. I don't know whether i'm right or not but it has some thing to do with mdecor property of the progressbar.
Following is the code I am using it.
pd = ProgressDialog.show(getActivity(), null, null,true);
pd.setContentView(R.layout.remove_border);
The code for remove border layout is:
<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>
The code for my_progress_indeterminate is:
<animated-rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:drawable="@drawable/loadingiconblack"
android:pivotX="50%"
android:pivotY="50%" />
Following is the image the background area is marked in red circle. I want to change color to white with same opacity.
EDIT:
Final solution to my issue thanks to Sripathi and user3298272 combining both solutions here is my updated answer:
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();
remove_border xml code: Here android:gravity = "center" is added in linear layout code of mine.
<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>
color xml code:
<resources>
<color name="transparent">#80FFFFFF</color>
</resources>
In #80FFFFFF 80 is the opacity value 50% which i took from user3298272.
Here is the transparent color ratio for the Hex color codes.
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
Just add the percentage of opacity before the color code. For example : color code for black is #0000. If i want transparent black with 50% transparency means just add 80 before #0000(i.e. #800000)
You can use dialog instead of 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);
Update:
Here the color transparent is #80FFFFFF
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With