android 实现由下至上弹出并位于屏幕底部的提示框

http://blog.csdn.net/centralperk/article/details/7494441

button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				AlertDialog dialog = new AlertDialog.Builder(TestAndroid1Activity.this)
						.setTitle("title").setMessage("message").create();
				Window window = dialog.getWindow();
				window.setGravity(Gravity.BOTTOM);  //此处可以设置dialog显示的位置
			    	window.setWindowAnimations(R.style.mystyle);  //添加动画
				dialog.show();
			}
		});

styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>

    <style name="mystyle" parent="android:Animation">
        <item name="@android:windowEnterAnimation">@anim/dialog_enter</item>  //进入时的动画
        <item name="@android:windowExitAnimation">@anim/dialog_exit</item>    //退出时的动画
    </style>
</resources>

位于 res/anim/dialog_enter.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
     
      <translate
          android:toYDelta="100%p"
          android:duration="600"    //持续时间
          />
</set>


位于 res/anim/dialog_exit.xml

<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
     
      <translate
          android:toYDelta="100%p"
          android:duration="600"    //持续时间
          />
</set>


上一篇:App 微信支付


下一篇:微信网页授权总结