【发布时间】:2010-09-24 07:18:21
【问题描述】:
在我的 android 应用程序中,我在启动画面中使用了进度对话框。 我只想看到没有背景的加载消息的进度条。 有什么方法可以在Android中将背景更改为透明?
请分享您的宝贵建议。
【问题讨论】:
标签: android android-layout user-interface
在我的 android 应用程序中,我在启动画面中使用了进度对话框。 我只想看到没有背景的加载消息的进度条。 有什么方法可以在Android中将背景更改为透明?
请分享您的宝贵建议。
【问题讨论】:
标签: android android-layout user-interface
ProgressBar 应该放在 Layout 上,然后您必须在 Activity 中设置或更改进度条。
在设置最大值、最小值、进度和文本之前请注意设置背景,否则将无法正确呈现。
【讨论】:
您可以通过在 xml 文件中定义进度条和文本来获取它,并在您的活动中控制它。
【讨论】:
正如 MGS 所说,您可以将 <Progressbar> 放入您的布局 xml 文件本身。此外,如果您想自定义 ProgressDialog,则必须学习 the CustomDialog Tutorial in the Documentation。它完全解释了有关 Dialog 的一切。
【讨论】:
您可以在自定义对话框的帮助下完成此操作,而不是使用进度对话框。 自定义对话框将是执行此操作的更好方法。 关注link。 你也可以使用
android:background="@android:color/transparent"
在父布局的背景属性中,以使其透明。
希望这能解决您的问题
【讨论】:
制作要在对话框中显示的布局 .xml 文件,然后创建对话框对象
对话框 dialog = new Dialog(main.this);
【讨论】:
创建对话框集,设置对话框样式如下:
<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>
例如:
Dialog dialog = new Dialog(main.this,R.style.CustomDialogTheme);
dialog.setContentView(<layout>);
只需将进度条放在布局中即可。
【讨论】: