【发布时间】:2017-07-04 06:20:54
【问题描述】:
我有一个包含三个标签的片段。在其中一个选项卡上,我有一个对话框,当后台同步进行时会旋转。但是当后台同步正在进行时,我需要能够继续处理其他部分。
我目前使用dialog.setCancelable(false) 退出对话框,以便我可以使用应用程序的其余部分。但这给了我在同步进行的片段上的情绪屏幕。
有没有什么办法让对话框只覆盖在屏幕的一部分上(只覆盖同步进行的片段)?换句话说,一个不占用整个屏幕的对话框,以便我可以在不取消对话框的情况下移动到其他选项卡?
java代码中对话框的实现:
dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_PROGRESS);
dialog.setCancelable(true);
dialog.setContentView(R.layout.dialog_progress_bar);
dialog.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
dialog.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ProgressBar
android:id="@+id/dialogProgressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</LinearLayout>
【问题讨论】:
-
为什么不在fragmnet 的xml 中直接使用
progressBar而不是在Dialog中显示它? -
是的,它有效。谢谢
标签: android android-fragments progressdialog