1.使用LayoutInflater.from(this).inflater(R.layout.mydialog,null)获取一个布局,存于View对象里面。
2.对View里面的控件进行动画处理。
3.创建Dialog对象,在对象形参里面添加两个属性,属性1:上下文,属性2:style。
4.调用setContentView()方法。方法里面有两个参数,1:布局文件。2:布局参数new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT,LinearLayout.LayoutParams.FILL_PARENT));
public class MyDialog {
Dialog dialog
RotateAnimation rotateAnimation
public void showDialog(Context context)
{
View view = LayoutInflater.from(context).inflate(R.layout.mydialog,null)
ImageView image = (ImageView) view.findViewById(R.id.image)
AnimationSet animationSet = new AnimationSet(true)
rotateAnimation = new RotateAnimation(0f,360000000f,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f)
rotateAnimation.setDuration(9900000)
animationSet.addAnimation(rotateAnimation)
image.startAnimation(animationSet)
dialog = new Dialog(context,R.style.mydialog)
dialog.setCancelable(false)
dialog.setContentView(view, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT))
dialog.show()
}
public void disMiss()
{
dialog.dismiss()
}
}