您好,欢迎来到保捱科技网。
搜索
您的当前位置:首页Xamarin.android Activity动画切换效果实现

Xamarin.android Activity动画切换效果实现

来源:保捱科技网

http:///esunshine1985/article/details/44302903

 

1.在Resources——values下新建styles.xml,添加内容如下:

[html]

2.在Resources下新建文件夹anim,在这个新建的文件夹下面新建四个文件,分别是

(1)slide_left_in.xml

[html]
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set  
  3.   xmlns:android="http://schemas.android.com/apk/res/android">  
  4.   <translate android:duration="300" android:fromXDelta="-100.0%p" android:toXDelta="0.0" />  
  5. </set>  

(2)slide_left_out.xml

[html]
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set  
  3.   xmlns:android="http://schemas.android.com/apk/res/android">  
  4.   <translate android:duration="300" android:fromXDelta="0.0" android:toXDelta="-100.0%p" />  
  5. </set>  

(3)slide_right_in.xml

[html]
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set  
  3.   xmlns:android="http://schemas.android.com/apk/res/android">  
  4.   <translate android:duration="300" android:fromXDelta="100.0%p" android:toXDelta="0.0" />  
  5. </set>  

(4)slide_right_out.xml

[html]
  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <set  
  3.   xmlns:android="http://schemas.android.com/apk/res/android">  
  4.   <translate android:duration="300" android:fromXDelta="0.0" android:toXDelta="100.0%p" />  
  5. </set>  

3.修改AndroidManifest.xml文件(红色标注的部分)

<application android:theme="@style/AppTheme"></application>
4.在MainActivity.cs中的切换按钮的代码:

[html]
  1. button.Click += delegate  
  2. {  
  3.     Intent intent = new Intent();  
  4.     intent.SetClass(this, typeof(Activity2));  
  5.     StartActivity(intent);  
  6.     OverridePendingTransition(Resource.Animation.slide_left_in, Resource.Animation.slide_right_out);  
  7. };  

 

转载于:https://www.cnblogs.com/LuoEast/p/8058021.html

因篇幅问题不能全部显示,请点此查看更多更全内容

Copyright © 2019- baoaiwan.cn 版权所有 赣ICP备2024042794号-3

违法及侵权请联系:TEL:199 18 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务