更改进度的Android半透明的背景颜色 [英] Changing translucent background color of progressbar android
问题描述
我想换有黑色半透明背景,不透明度小于50%的进度的背景色。 我搜索了很多关于这一点,但没能找到解决方案。 我不知道我是否正确与否,但它有一些事情与进度的mdecor属性。
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.
以下是code我使用它。
Following is the code I am using it.
pd = ProgressDialog.show(getActivity(), null, null,true);
pd.setContentView(R.layout.remove_border);
在$ C $下删除边框布局是:
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>
在$ C $下my_progress_indeterminate是:
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.
编辑:
最终解决我到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();
remove_border XML code: 在这里,Android的:重力=中心在我的线性布局code添加
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>
色XML code:
color xml code:
<resources>
<color name="transparent">#80FFFFFF</color>
</resources>
在#80FFFFFF 80是不透明度值50%,这是我从user3298272了。
In #80FFFFFF 80 is the opacity value 50% which i took from user3298272.
推荐答案
您可以用对话代替progressdialog,
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);
更新:
Here the color transparent is #80FFFFFF
这篇关于更改进度的Android半透明的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!