如何减少进度对话框的高度和宽度?

时间:2012-03-28 02:59:56

标签: android

我想减小进度对话框的高度和宽度,并在屏幕中间将其显示得更小。

3 个答案:

答案 0 :(得分:2)

你可以使用assync任务...制作图像的图形并应用旋转动画..在这个mAnimation中你想要旋转的imageview ...把​​这个imageview放在屏幕的中心并在post执行后隐藏。在post执行清除动画并做其他事情

 private class LoadAssync extends AsyncTask<String, Void, Void> {

    protected void onPreExecute() {
        mAnimation.startAnimation(anim);
    }

    protected Void doInBackground(final String... args) {
        //do the task here

    }

    protected void onPostExecute(final Void unused) {
        mAnimation.clearAnimation();
                    mAnimation.setVisibility(View.GONE); 

    }


}

在rotation.xml中

  <rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1200"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="360"
android:interpolator="@android:anim/linear_interpolator" >

 </rotate>

希望这会有所帮助

答案 1 :(得分:1)

您需要做的就是创建宽度设置为wrap_content

的自定义样式
<style name="DialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
    <!--Other custom stuff if needed-->
    <item name="android:layout_width">wrap_content</item>
</style>

然后将此样式添加到ProgressDialog

final ProgressDialog mDialog = new ProgressDialog(getActivity(), R.style.DialogStyle);
mDialog.setMessage("Loading... Please wait...");
mDialog.setCancelable(false);
mDialog.show();
mDialog.setContentView(avLoadingIndicatorView);

演示

enter image description here

答案 2 :(得分:0)

请参阅

中给出的答案

How to reduce the size of Progressdialog in android?

接受提示并解决您的问题:)

相关问题