gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-29 02:33:30 25 4
gpt4 key购买 nike

我想在 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>

微调器根本没有动画: static spinner

最佳答案

试试下面的代码,这对你有帮助:

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();

关于android - 如何在 Dialog Android 中添加移动进度微调器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48382008/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com