亦余心之所善兮,虽九死其犹未悔。这篇文章主要讲述Xamarin.android Activity动画切换效果实现相关的知识,希望能为你提供帮助。
http://blog.csdn.net/esunshine1985/article/details/44302903
1.在Resources——values下新建styles.xml,添加内容如下:
[html] view plain copy
- < resources xmlns:android="http://schemas.android.com/apk/res/android">
- < style name="AppTheme" parent="@android:style/Theme">
- < item name="android:windowNoTitle"> true< /item> < !-- 设置没有标题 -->
- < item name="android:textSize"> 20sp< /item> < !-- 设置文本大小 -->
- < item name="android:textColor"> #F34141< /item>
- < item name="android:background"> @android:color/background_light< /item>
- < !-- 设置activity切换动画 -->
- < item name="android:windowAnimationStyle"> @style/activityAnimation< /item>
- < /style>
- < !-- animation 样式 -->
- < style name="activityAnimation" parent="@android:style/Animation">
- < item name="android:activityOpenEnterAnimation"> @anim/slide_right_in< /item>
- < item name="android:activityCloseExitAnimation"> @anim/slide_right_out< /item>
- < item name="android:activityOpenExitAnimation"> @anim/slide_left_out< /item>
- < item name="android:activityCloseEnterAnimation"> @anim/slide_left_in< /item>
- < /style>
- < /resources>
(1)slide_left_in.xml
[html] view plain copy
- < ?xml version="1.0" encoding="utf-8"?>
- < set
- xmlns:android="http://schemas.android.com/apk/res/android">
- < translate android:duration="300" android:fromXDelta="-100.0%p" android:toXDelta="0.0" />
- < /set>
[html] view plain copy
- < ?xml version="1.0" encoding="utf-8"?>
- < set
- xmlns:android="http://schemas.android.com/apk/res/android">
- < translate android:duration="300" android:fromXDelta="0.0" android:toXDelta="-100.0%p" />
- < /set>
[html] view plain copy
- < ?xml version="1.0" encoding="utf-8"?>
- < set
- xmlns:android="http://schemas.android.com/apk/res/android">
- < translate android:duration="300" android:fromXDelta="100.0%p" android:toXDelta="0.0" />
- < /set>
[html] view plain copy
- < ?xml version="1.0" encoding="utf-8"?>
- < set
- xmlns:android="http://schemas.android.com/apk/res/android">
- < translate android:duration="300" android:fromXDelta="0.0" android:toXDelta="100.0%p" />
- < /set>
< application android:theme="@style/AppTheme"> < /application>
4.在MainActivity.cs中的切换按钮的代码:
[html] view plain copy
- button.Click += delegate
- {
- Intent intent = new Intent();
- intent.SetClass(this, typeof(Activity2));
- StartActivity(intent);
- OverridePendingTransition(Resource.Animation.slide_left_in, Resource.Animation.slide_right_out);
- };
推荐阅读
- 2017.12.18 Android开发之进程讲解
- Android异步消息机制
- 通用Mapper新特性(ExampleBuilder 2017年12月18日)
- Android 跨进程启动Activity黑屏(白屏)的三种解决方案
- Android HandlerThread 源码分析
- Android系统常用URI
- android webview处理h5打开本地文件浏览器的功能
- androidcarsh
- angular 分离app.module.ts代码