繁体   English   中英

如何在Dialog Android中添加移动进度微调器

[英]How to add a moving progress spinner in Dialog Android

我想将微调框放在android的自定义对话框中,但是任何人都不知道为什么没有动画。

Dialog dialog = new Dialog(this,R.style.mydialog);
dialog.setContentView(R.layout.dialog);
dialog.show();

将dialog.xml粘贴在下面:

<LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:gravity="center">
        <ProgressBar
            android:layout_width="@dimen/progressbar_width"
            android:layout_height="@dimen/progressbar_height"
            android:layout_marginTop="@dimen/progressbar_margin"
            android:layout_marginBottom="@dimen/progressbar_margin"
            android:indeterminateTint="@color/light_blue"
            android:indeterminateTintMode="src_atop"
            />
        <TextView
            android:id="@+id/dialog_loading_message"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="@dimen/progressbar_margin"
            android:gravity="center"
            android:textColor="@android:color/white"
            android:textSize="@dimen/progressbar_message_text_size"
            android:visibility="gone"
            />
    </LinearLayout>

微调框根本没有动画: 静态微调器

试试下面的代码,这将帮助您:

if (dialog == null) {
        dialog = new Dialog(this);
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
        dialog.setContentView(R.layout.dialog);

    }
    RotateAnimation rotate = new RotateAnimation(0, 360,
            Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF,
            0.5f);
    rotate.setDuration(2000);
    rotate.setRepeatCount(Animation.INFINITE);
    dialog.findViewById(R.id.ivProgress).setAnimation(rotate);
    dialog.show();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM