来自:http://blog.csdn.net/shenggaofei/article/details/52122966

动画效果Activity淡入,同按钮布局有屏幕底部向上推出,代码比较简单就不在这里详细介绍。
 
1.首先创建一个,的布局文件clearpan.xml,这个文件就是从下到上弹出的布局文件。

    

[html]  view plain  copy  
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"  
  3.     android:layout_width="fill_parent"  
  4.     android:layout_height="fill_parent"  
  5.       
  6.     android:orientation="vertical" >  
  7.       
  8.       
  9.  <RelativeLayout   
  10.      android:id="@+id/clearallpan"  
  11.      android:layout_width="fill_parent"  
  12.      android:layout_height="wrap_content"  
  13.      android:layout_alignParentBottom="true"  
  14.      android:background="@drawable/incall_bg"  
  15.      >  
  16.        
  17.      <Button   
  18.          android:id="@+id/clearall"  
  19.          android:layout_width="fill_parent"  
  20.          android:layout_height="wrap_content"  
  21.          android:layout_marginLeft="10dip"  
  22.          android:layout_marginRight="10dip"  
  23.          android:layout_marginTop="20dip"  
  24.          android:layout_marginBottom="10dip"  
  25.       android:background="@drawable/iphonesms_smsdetail_delete_deleteall"  
  26.          android:text="删除所有"  
  27.          android:textColor="#FFFFFFFF"/>  
  28.        
  29.      <Button   
  30.          android:id="@+id/cancel"  
  31.          android:layout_width="fill_parent"  
  32.          android:layout_height="wrap_content"  
  33.          android:layout_marginLeft="10dip"  
  34.          android:layout_marginRight="10dip"  
  35.          android:layout_marginTop="10dip"  
  36.          android:layout_marginBottom="20dip"  
  37.            
  38.          android:text="取消"  
  39.       android:background="@drawable/iphonesms_smsdetail_delete_forwardall"  
  40.          android:layout_below="@id/clearall"  
  41.          android:textColor="#FFFFFFFF"/>  
  42.        
  43.  RelativeLayout>  
  44.       
  45. RelativeLayout>  

2.在anim文件夹下,定义动画效果文件

[html]  view plain  copy  
  1. <?xml version="1.0" encoding="utf-8"?>  
  2.   
  3.   
  4.   
  5. <set xmlns:android="http://schemas.android.com/apk/res/android"  
  6.     android:interpolator="@android:anim/accelerate_interpolator" >  
  7.     <translate  
  8.         android:duration="300"  
  9.         android:fromYDelta="100.0%"  
  10.         android:toYDelta="10.000002%" />  
  11.     <alpha  
  12.         android:duration="50"  
  13.         android:fromAlpha="0.0"  
  14.         android:toAlpha="1.0" />  
  15. set>  


3 .创建AnimationActivity.Java代码类。

[java]  view plain  copy  
  1.  public class AnimationActivity extends Activity {  
  2.    private Button mBtu;  
  3.    private String mStr;  
  4.     /** Called when the activity is first created. */  
  5.     @Override  
  6.     public void onCreate(Bundle savedInstanceState) {  
  7.         super.onCreate(savedInstanceState);  
  8.         setContentView(R.layout.main);  
  9.         mBtu = (Button) findViewById(R.id.clear);  
  10.         mBtu.setOnClickListener(new OnClickListener() {  
  11.          private AlertDialog dlg = null;  
  12.            
  13.    Button mCancelBtn = null;  
  14.    Button mClearAllBtn = null;  
  15.      
  16.    @Override  
  17.    public void onClick(View v) {  
  18.     this.dlg = new AlertDialog.Builder(AnimationActivity.this)  
  19.     .create();  
  20.   View localView = AnimationActivity.this.getLayoutInflater()  
  21.     .inflate(R.layout.clearpan, null);  
  22.   localView.setAnimation(AnimationUtils.loadAnimation(  
  23.     AnimationActivity.this, R.anim.slide_bottom_to_top));  
  24.   Window localWindow = this.dlg.getWindow();  
  25.   localWindow.getAttributes();  
  26.   this.dlg.show();  
  27.   localWindow.setContentView(localView);  
  28.   localWindow.setGravity(Gravity.BOTTOM);  
  29.   localWindow.setLayout(-1280);  
  30.   this.mClearAllBtn = ((Button) this.dlg  
  31.     .findViewById(R.id.clearall));  
  32.   this.mCancelBtn = ((Button) this.dlg  
  33.     .findViewById(R.id.cancel));  
  34.   this.mClearAllBtn.setOnClickListener(new View.OnClickListener() {  
  35.    public void onClick(View paramView) {  
  36.     finish();  
  37.    }  
  38.   });  
  39.     
  40.   this.mCancelBtn.setOnClickListener(new View.OnClickListener() {  
  41.    public void onClick(View paramView) {  
  42.     dlg.cancel();  
  43.    }  
  44.   });  
  45.    }  
  46.      
  47.   });  
  48.           
  49.     }  
  50. }  

更多相关文章

  1. Android(安卓)手机sdcard目录或文件的拷贝、移动、删除(递归)
  2. Android中AppWidget加载流程(二)
  3. ReactNative对接Android步骤
  4. Android(安卓)流式布局
  5. 在eclipse里卸载已安装的插件[例如Android(安卓)Development Too
  6. android 读取文件相关
  7. Android(安卓)ramdisk.img system.img userdata.img介绍与使用
  8. 腾讯Bugly的使用
  9. Android(安卓)5.0新特性之Material Design

随机推荐

  1. 如何获取Android源码
  2. C++和android进行socket通信小结
  3. Android(安卓)开发中使用 SQLite 数据库
  4. android 访问web端与解析json,模拟用户登
  5. android播放提示音工具类(SoundConfigUti
  6. Android布局之相对布局——RelativeLayou
  7. Android开发9——Activity的启动模式
  8. 关于android读取ICCID、IMSI和IMEI
  9. Android(安卓)FrameWork——Touch事件派
  10. Android中级进阶 FAQ