Android 如何使用动画重新调整对话框大小

Android 如何使用动画重新调整对话框大小,android,animation,dialog,Android,Animation,Dialog,我在对话框xml布局中创建了一个自定义对话框类扩展了dialog 我用动画展开/折叠textview,效果很好, 但是当我展开或折叠textview的视图时,对话框的大小也会随着动画的变化而变化,如何使它也随着动画的变化而重新调整大小呢 public class ErrorDialog extends Dialog { private String err; private TextView txt_help_gest; public ErrorDialogOnClickListen

我在对话框xml布局中创建了一个自定义对话框类扩展了dialog 我用动画展开/折叠textview,效果很好, 但是当我展开或折叠textview的视图时,对话框的大小也会随着动画的变化而变化,如何使它也随着动画的变化而重新调整大小呢

public class ErrorDialog extends Dialog {

private String err;
private  TextView  txt_help_gest;


 public ErrorDialogOnClickListener errorDialogListener;
 private String shortDesc;

private Animation slide_up_Animation;
private Animation slide_down_Animation;

private Animation rotate_arrow_down;
private Animation rotate_arrow_up;

public ErrorDialog(Context context,String shortDesc, String err, ErrorDialogOnClickListener errorDialogListener) {
    super(context);
    this.err=err;
    this.errorDialogListener = errorDialogListener;
    this.shortDesc=shortDesc;

    slide_up_Animation= AnimationUtils.loadAnimation(context, R.anim.slide_up);
    slide_down_Animation= AnimationUtils.loadAnimation(context, R.anim.slide_down);

    rotate_arrow_down= AnimationUtils.loadAnimation(context, R.anim.rotate_arrow_down);
    rotate_arrow_up= AnimationUtils.loadAnimation(context, R.anim.rotate_arrow_up);
    getWindow().getAttributes().windowAnimations = R.style.Animations_SmileWindow;

}
@Override
public void onCreate(Bundle savedInstanceState) {


    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.dialog_error);

    setTitle("שגיאה");
    setCancelable(false);
    // set values for custom dialog components - text, image and button
    Button btnClose=(Button)findViewById(R.id.btnClose);
    TextView text = (TextView) findViewById(R.id.textDialog);
    txt_help_gest = (TextView) findViewById(R.id.txt_help_gest);
    //help_title_gest = (TextView) findViewById(R.id.help_title_gest);
    final ImageView imgArrow = (ImageView) findViewById(R.id.imgArrow);
    LinearLayout ll_help_title = (LinearLayout) findViewById(R.id.ll_help_title);


   // ll = (View) findViewById(R.id.ll);
    text.setText(shortDesc+"\n התוכנית תסגר.");
    txt_help_gest.setText(err);

    txt_help_gest.setVisibility(View.GONE);


    ll_help_title.setOnClickListener(new android.view.View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            //txt_help_gest.clearAnimation();

            if(txt_help_gest.isShown()){
                 //collapse();
                //slide_up_Animation.reset();
                 txt_help_gest.startAnimation(slide_up_Animation);

                txt_help_gest.setVisibility(View.GONE);

                imgArrow.startAnimation(rotate_arrow_up);

              }
              else{
                 // expand();
                //  slide_down_Animation.reset();
                txt_help_gest.setVisibility(View.VISIBLE);
                txt_help_gest.startAnimation(slide_down_Animation);
                imgArrow.startAnimation(rotate_arrow_down);
              }

        }
    });
    btnClose.setOnClickListener(new android.view.View.OnClickListener() {

        @Override
        public void onClick(View arg0) {
            errorDialogListener.onButtonClick();  
            dismiss();
        }
    });

}
 public interface ErrorDialogOnClickListener {
        void onButtonClick();
    }

}

向我们展示一些源代码总是有帮助的;我添加了dialog类源代码