change progressdialog background
In my android application I am using progress dialog in my splashscreen. I would like to see only the progressbar with loading message without the background. Is there any way that I can change the background 开发者_如何学Pythonto transparent in Android?
Please share your valuable suggestions.
ProgressBar should be placed on the Layout and then you have to set or change the progressbar in your activity.
Beware of setting the background before setting max, min, progress and text or it will not render correctly.
you can get it by defining the progressbar and the text in your xml file and you control it in your activity.
As MGS says, you can put the <Progressbar>
in your layout xml file itself. Moreover you want to customize your ProgressDialog then you have to study the CustomDialog Tutorial in the Documentation. It explains everything about Dialog completely.
You can do this with the help of custom dialog instead of using progress dialog. Custom dialog will be a better approach to do this . Follow the link. You can also use
android:background="@android:color/transparent"
in the background property of the parent layout in order to make it transparent.
Hope this will solve your problem
make layout .xml file which you want to display in Dialog then Create Object of Dialog
Dialog dialog = new Dialog(main.this);
- dialog.setContentView(R.layout."your_layout");
- dialog.setTitle("This is my custom dialog box");
- dialog.setCancelable(true);
Create a dialog set set the dialog style to following:
<style name="CustomDialogTheme" parent="@android:style/Theme.Dialog">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowIsFloating">false</item>
<item name="android:windowNoTitle">true</item>
</style>
For ex:
Dialog dialog = new Dialog(main.this,R.style.CustomDialogTheme);
dialog.setContentView(<layout>);
Just put your progress bar in layout.
精彩评论