android 底部弹出dailog

来源:互联网 发布:淘宝代销产品图片搬家 编辑:程序博客网 时间:2024/04/27 22:59

1、系统框弹出:

AlertDialog dialog = new AlertDialog.Builder(VipActivity.this)              .setTitle("title").setMessage("message").create();      Window window = dialog.getWindow();      window.setGravity(Gravity.BOTTOM);         window.setWindowAnimations(R.style.mystyle);       dialog.show(); 

2、自定义弹出弹出:

final AlertDialog dialog = new AlertDialog.Builder(context).create();        LayoutInflater inflater = LayoutInflater.from(context);        View rootView = inflater.inflate(R.layout.dialog_integral, null);        Button btnLeft = (Button) rootView.findViewById(R.id.btn_left);        Button btnRight = (Button) rootView.findViewById(R.id.btn_right);        dialog.setView(rootView);        Window window = dialog.getWindow();        window.setGravity(Gravity.BOTTOM);         window.setWindowAnimations(R.style.mystyle);         dialog.show();

3、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>  

4、位于 res/anim/dialog_enter.xml

<?xml version="1.0" encoding="utf-8"?>  <set xmlns:android="http://schemas.android.com/apk/res/android">      <translate          android:fromYDelta="100%p"       %p指相对于父容器          android:duration="600"          />  </set>  

5、位于 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>   
0 0
原创粉丝点击