我试图在我的xamarin表单应用中添加原生感觉动画,以增加专业效果。
我已覆盖导航页面渲染器,使用以下代码在转场上实现我自己的动画......
function popup(idn, roletype, un, ps, em, urid, firstname, lastname, phone,address) {
var $dropdown = $("#roletype");
$("#userid").val(idn);
$("#UserRoleID").val(urid);
$dropdown.val(urid);
$("#usern").val(un);
$("#pwd").val(ps);
$("#txtFirstName").val(firstname);
$("#txtLastname").val(lastname);
$("#txtPhone").val(phone);
$("#eml").val(em);
$("#txtAddress").val(address);
$("#popupdiv").dialog({
width: 1080,
height: 550,
autoOpen: true,
modal: true,
open: function (event, ui) {
$(".ui-dialog-titlebar-close", ui.dialog | ui).hide();
},
buttons: {
Close: function () {
$(this).dialog("close");
}
}
});
}
我的问题是,当我使用Navigation.PopAsync()弹出页面时,弹出页面会在有机会动画之前隐藏。这意味着输入页面将飞入一个空视图,而不是从当前页面后面出现。
有人有解决方法吗?
动画低于......
enter_from_left.xml
[assembly: ExportRenderer(typeof(NavigationPage), typeof(NavigationPageCustomRenderer))]
namespace App1.Droid
{
public class NavigationPageCustomRenderer : Xamarin.Forms.Platform.Android.AppCompat.NavigationPageRenderer
{
public NavigationPageCustomRenderer(Context context) : base(context)
{
}
protected override void SetupPageTransition(FragmentTransaction transaction, bool isPush)
{
if (isPush)
transaction.SetCustomAnimations(Resource.Animation.enter_from_right, Resource.Animation.exit_to_left);
else
{
transaction.SetCustomAnimations(Resource.Animation.enter_from_left, Resource.Animation.exit_to_right);
}
}
}
}
enter_from_right.xml
<?xml version="1.0" encoding="utf-8" ?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="-10%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300" />
</set>
exit_to_left.xml
<?xml version="1.0" encoding="utf-8" ?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:propertyName="enter_from_left"
android:shareInterpolator="false">
<translate
android:fromXDelta="100%" android:toXDelta="0%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300"/>
</set>
exit_to_right.xml
<?xml version="1.0" encoding="utf-8" ?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:shareInterpolator="false">
<translate
android:fromXDelta="0%" android:toXDelta="-5%"
android:fromYDelta="0%" android:toYDelta="0%"
android:duration="300" />
</set>
答案 0 :(得分:-1)
点击按钮后尝试使用此代码。
Device.BeginInvokeOnMainThread(async () =>
{
Navigation.PopAsync()
}