android - 在 xamarin 形式的初始屏幕中动画或从底部到顶部的过渡?
问题描述
我试图在初始屏幕的底部有一个带有徽标的背景图像。一旦在 ios 和 Android(xamarin 表单)中加载初始屏幕,就会发生从底部到中心的转换。请分享你的想法?
解决方案
如果要动画启动画面,请按照以下步骤操作。我在 Android 中做了一个示例。
首先,请创建 SplashScreen.axml。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageView1"
android:src="@drawable/splash_logo"
android:gravity="bottom|center_horizontal"/>
</LinearLayout>
其次,在Resource文件夹下创建Anim文件夹,创建bottomtotop.xml关于翻译的动画。
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/linear_interpolator">
<translate
android:fromYDelta="100%p"
android:toYDelta="0"
android:duration="600"/>
</set>
第三,使用动画创建新的活动名称 SplashScreenDemo.cs。设置 MainLauncher = true。
[Activity(Label = "SplashScreenDemo", MainLauncher = true)]
public class SplashScreenDemo : Activity
{
ImageView imageView;
Animation view_animation;
TextView textview;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.SplashScreen);
imageView = FindViewById<ImageView>(Resource.Id.imageView1);
view_animation = AnimationUtils.LoadAnimation(this, Resource.Animation.bottomtotop);
imageView.StartAnimation(view_animation);
view_animation.AnimationEnd += Rotate_AnimationEnd;
// Create your application here
}
private void Rotate_AnimationEnd(object sender, Animation.AnimationEndEventArgs e)
{
// Finish();
Intent intent;
intent = new Intent(Application.Context, typeof(MainActivity));
StartActivity(intent);
}
}
推荐阅读
- php - react.js 代码中的简单 HTML 元素在 Xampp localhost 中不起作用
- typo3 - 如何创建可在 Typo3 v10 中进行后端管理的时事通讯
- c - 如何比较 Go 中的 errno?
- flutter - 使用 Firebase 推送通知时 Flutter App 崩溃
- reactjs - React.js 中 useEffect 的奇怪行为
- python - Pillow 是在没有 XCB 支持错误的情况下构建的
- json - spark在解析JSON文件时显示NULL值
- postgresql - Grafana PostgreSQL 与时间序列不同 on()
- python - 如何在 discord.py 中获取实际用户并排除机器人?
- python - 过滤数据并使用逗号分隔值进行查找