private void ShowFab(FloatingActionButton fab, float tx, float ty, int index) { switch (type) { case AnimationType.Explosion: var endAction = new Runnable(() => fab.Clickable = true); fab.Visibility = ViewStates.Visible; fab.Animate().TranslationX(-tx).TranslationY(-ty).SetDuration(150).SetStartDelay(0).WithEndAction(endAction).Start(); fab.Animate().ScaleX(1).ScaleY(1).SetDuration(150).SetStartDelay(0).WithEndAction(endAction).Start(); break; case AnimationType.Fade: fab.TranslationX = -tx; fab.TranslationY = -ty; fab.Alpha = 0; fab.Visibility = ViewStates.Visible; fab.Animate().Alpha(1.0f).SetDuration(800).SetStartDelay(index * 200).Start(); fab.Clickable = true; break; case AnimationType.None: fab.TranslationX = -tx; fab.TranslationY = -ty; fab.Visibility = ViewStates.Visible; fab.Clickable = true; break; } }
private void AnimateMenu(bool opening) { if (opening != IsMenuOpened) { ProcessFabs(); if (opening) { container.SetBackgroundColor(Color.ParseColor("#80000000")); if (mainWithAnimation) { mainFab.Animate().Rotation(45).SetDuration(300).Start(); } } else { container.SetBackgroundColor(Color.Transparent); if (mainWithAnimation) { mainFab.Animate().Rotation(0).SetDuration(300).Start(); } } IsMenuOpened = opening; } }
private void CloseFabMenu() { if (BottomSheetBehavior.From(bottomSheet).State != BottomSheetBehavior.StateExpanded) { ReloadMapEventMarkers(); bottomSheet.Animate().TranslationY(0); isFabOpen = false; fabMain.Animate().Rotation(0f); bgFabMenu.Animate().Alpha(0f); fabEvents.Animate() .TranslationY(0) .Rotation(90f); fabAccount.Animate() .TranslationY(0) .Rotation(90f); fabSettings.Animate() .TranslationY(0) .Rotation(90f); fabLogin.Animate() .TranslationY(0) .Rotation(90f).SetListener(new FabAnimatorListener(bgFabMenu, fabEvents, fabAccount, fabSettings, fabLogin)); } }
private void ShowFAB() { mFAB.Animate().ScaleX(1f).ScaleY(1f) .SetInterpolator(new OvershootInterpolator()) .Start(); mFAB.Clickable = true;// SetClickable(true); }
private void openMenu() { isMenuOpen = !isMenuOpen; fabMain.Animate().SetInterpolator(interpolator).Rotation(45f).SetDuration(300).Start(); fabOne.Animate().TranslationY(0f).Alpha(1f).SetInterpolator(interpolator).SetDuration(300).Start(); fabTwo.Animate().TranslationY(0f).Alpha(1f).SetInterpolator(interpolator).SetDuration(300).Start(); fabThree.Animate().TranslationY(0f).Alpha(1f).SetInterpolator(interpolator).SetDuration(300).Start(); fabfour.Animate().TranslationY(0f).Alpha(1f).SetInterpolator(interpolator).SetDuration(300).Start(); }
private void CloseFabMenu() { isfabOpen = false; fabAccount1.Visibility = ViewStates.Visible; fabAccount2.Visibility = Android.Views.ViewStates.Visible; bgFabMenu.Visibility = Android.Views.ViewStates.Visible; fabMain.Animate().Rotation(90f); bgFabMenu.Animate().Alpha(1f); fabAccount1.Animate() .TranslationY(0f) .Rotation(90f); fabAccount2.Animate() .TranslationY(0f) .Rotation(90f).SetListener(new FabAnimatorListener(bgFabMenu, fabAccount1, fabAccount2)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_style_taurus); mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar); mToolbar.NavigationClick += (sender, e) => { Finish(); }; mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout; if (isFirstEnter) { isFirstEnter = false; mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果 } mAppBarLayout = FindViewById <AppBarLayout>(Resource.Id.app_bar); mToolbarLayout = FindViewById <CollapsingToolbarLayout>(Resource.Id.toolbar_layout); var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); recyclerView.SetItemAnimator(new DefaultItemAnimator()); recyclerView.SetLayoutManager(new LinearLayoutManager(this)); recyclerView.AddItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.Vertical)); recyclerView.SetAdapter(new CustomBaseRecyclerAdapter(Item.List, Android.Resource.Layout.SimpleListItem2, this)); // 监听 AppBarLayout 的关闭和开启 给 FlyView(纸飞机) 和 ActionButton 设置关闭隐藏动画 mActionButton = FindViewById <FloatingActionButton>(Resource.Id.fab); mAppBarLayout.OffsetChanged += (sender, e) => { var appBarLayout = e.AppBarLayout; var verticalOffset = e.VerticalOffset; int scrollRange = appBarLayout.TotalScrollRange; float fraction = 1f * (scrollRange + verticalOffset) / scrollRange; if (fraction < 0.1 && misAppbarExpand) { misAppbarExpand = false; mActionButton.Animate().ScaleX(0).ScaleY(0); } if (fraction > 0.8 && !misAppbarExpand) { misAppbarExpand = true; mActionButton.Animate().ScaleX(1).ScaleY(1); } }; }
public static FloatingActionButton ShowWithTranslateAnimation(this FloatingActionButton actionButton) { actionButton.Animate() .TranslationY(0) .SetInterpolator(new DecelerateInterpolator(2f)) .Start(); return(actionButton); }
private void ShowFabMenu() { isFabOpen = true; floatingButton2.Visibility = ViewStates.Visible; floatingButton3.Visibility = ViewStates.Visible; floatingButton4.Visibility = ViewStates.Visible; floatingButton1.Animate().Rotation(135f); floatingButton2.Animate() .TranslationY(-270) .Rotation(360f); floatingButton3.Animate() .TranslationY(-380) .Rotation(360f); floatingButton4.Animate() .TranslationY(-160) .Rotation(360f); }
public static FloatingActionButton HideWithTranslateAnimation(this FloatingActionButton actionButton) { var marginLayoutParams = actionButton.LayoutParameters as ViewGroup.MarginLayoutParams; int margin = marginLayoutParams?.BottomMargin ?? 0; actionButton.Animate() .TranslationY(actionButton.Height + margin) .SetInterpolator(new AccelerateInterpolator(2f)) .Start(); return(actionButton); }
private void HideFab(FloatingActionButton fab, float tx, float ty, int index) { switch (type) { case AnimationType.Explosion: var endActionExp = new Runnable(() => fab.Visibility = ViewStates.Gone); fab.Clickable = false; fab.Animate().TranslationX(tx).TranslationY(ty).SetDuration(150).SetStartDelay(0).WithEndAction(endActionExp).Start(); fab.Animate().ScaleX(0).ScaleY(0).SetDuration(150).SetStartDelay(0).WithEndAction(endActionExp).Start(); break; case AnimationType.Fade: var endActionFade = new Runnable(() => { fab.TranslationX = tx; fab.TranslationY = ty; fab.Visibility = ViewStates.Gone; fab.Alpha = 1.0f; }); fab.Clickable = false; fab.Animate().Alpha(0).SetDuration(800).SetStartDelay(index * 200).WithEndAction(endActionFade).Start(); break; case AnimationType.None: fab.TranslationX = tx; fab.TranslationY = ty; fab.Visibility = ViewStates.Gone; fab.Clickable = false; break; } }
private void OnSlideChanged(View bs, float slideOffset) { fbMute.Animate().ScaleX(1 - slideOffset).ScaleY(1 - slideOffset).SetDuration(0).Start(); ivSheetArrow.Rotation = (1 - slideOffset) * 180; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_fly_refresh); toolbar = FindViewById <Toolbar>(Resource.Id.toolbar); SetSupportActionBar(toolbar); toolbar.NavigationClick += (sender, e) => { Finish(); }; /************************************************************ * 关键代码-开始 ************************************************************/ mFlyView = FindViewById <FlyView>(Resource.Id.flyview); mScenceView = FindViewById <MountanScenceView>(Resource.Id.mountan); mFlyRefreshHeader = FindViewById <FlyRefreshHeader>(Resource.Id.flyrefresh); mFlyRefreshHeader.SetUp(mScenceView, mFlyView); //绑定场景和纸飞机 mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout; mRefreshLayout.SetReboundInterpolator(new ElasticOutInterpolator()); //设置回弹插值器,会带有弹簧震动效果 mRefreshLayout.SetReboundDuration(800); //设置回弹动画时长 mRefreshLayout.SetOnRefreshListener(new CustomOnRefreshListener(this)); //设置 让 AppBarLayout 和 RefreshLayout 的滚动同步 并不保持 toolbar 位置不变 appBar = FindViewById <AppBarLayout>(Resource.Id.app_bar); mRefreshLayout.SetOnMultiPurposeListener(new CustomOnMultiPurposeListener(this)); /************************************************************ * 关键代码-结束 ************************************************************/ mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout; if (isFirstEnter) { isFirstEnter = false; mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果 } /** * 初始化列表数据 */ initDataSet(); mAdapter = new ItemAdapter(this); mLayoutManager = new LinearLayoutManager(this); mListView = FindViewById <RecyclerView>(Resource.Id.recyclerView); mListView.SetLayoutManager(mLayoutManager); mListView.SetAdapter(mAdapter); mListView.SetItemAnimator(new SampleItemAnimator()); mToolbarLayout = FindViewById <CollapsingToolbarLayout>(Resource.Id.toolbar_layout); mActionButton = FindViewById <FloatingActionButton>(Resource.Id.fab); //设置点击 ActionButton 时候触发自动刷新 并改变主题颜色 mActionButton.Click += (sender, e) => { updateTheme(); mRefreshLayout.AutoRefresh(); }; // 监听 AppBarLayout 的关闭和开启 给 FlyView(纸飞机) 和 ActionButton 设置关闭隐藏动画 appBar.OffsetChanged += (sender, e) => { var appBarLayout = e.AppBarLayout; var verticalOffset = e.VerticalOffset; int scrollRange = appBarLayout.TotalScrollRange; float fraction = 1f * (scrollRange + verticalOffset) / scrollRange; if (fraction < 0.1 && misAppbarExpand) { misAppbarExpand = false; mActionButton.Animate().ScaleX(0).ScaleY(0); mFlyView.Animate().ScaleX(0).ScaleY(0); ValueAnimator animator = ValueAnimator.OfInt(mListView.PaddingTop, 0); animator.SetDuration(300); animator.Update += (senderr, ee) => { mListView.SetPadding(0, (int)ee.Animation.AnimatedValue, 0, 0); }; animator.Start(); } if (fraction > 0.8 && !misAppbarExpand) { misAppbarExpand = true; mActionButton.Animate().ScaleX(1).ScaleY(1); mFlyView.Animate().ScaleX(1).ScaleY(1); ValueAnimator animator = ValueAnimator.OfInt(mListView.PaddingTop, DensityUtil.Dp2px(25)); animator.SetDuration(300); animator.Update += (senderr, ee) => { mListView.SetPadding(0, (int)ee.Animation.AnimatedValue, 0, 0); }; animator.Start(); } }; //状态栏透明和间距处理 StatusBarUtil.immersive(this); StatusBarUtil.setPaddingSmart(this, toolbar); // StatusBarUtil.setPaddingSmart(this, findViewById(R.id.profile)); // StatusBarUtil.setPaddingSmart(this, findViewById(R.id.blurview)); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); CheckForPermissions(); Instance = this; //Window.AddFlags(WindowManagerFlags.Fullscreen); //to show Settings.LoadFromFile(); imageStore.LoadFavorites(); AdView adView = new AdView(this) { AdSize = AdSize.SmartBanner, AdUnitId = "ca-app-pub-3940256099942544/6300978111" }; CoordinatorLayout cLayout = FindViewById <CoordinatorLayout>(Resource.Id.coordinatorLayout); cLayout.AddView(adView); adView.TranslationY = (PhoneHeight - adView.AdSize.GetHeightInPixels(this) - GetStatusBarHeight()); //SetAdView MobileAds.Initialize(this, "ca-app-pub-3940256099942544~3347511713"); adView.LoadAd(adRequest); CrossConnectivity.Current.ConnectivityChanged += (o, e) => { RunOnUiThread(() => { //SetAdView when the connection changes MobileAds.Initialize(this, "ca-app-pub-3940256099942544~3347511713"); adView.LoadAd(adRequest); }); }; //Finding Resources tagSpinner = FindViewById <Spinner>(Resource.Id.apiEndPoints); imagePanel = FindViewById <ImageView>(Resource.Id.imageView); imageInfoButton = FindViewById <FloatingActionButton>(Resource.Id.imageInfoButton); nextImageButton = FindViewById <FloatingActionButton>(Resource.Id.nextImageButton); previousImageButton = FindViewById <FloatingActionButton>(Resource.Id.previousImageButton); Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar); imageInfoButton.Animate().TranslationY(PhoneHeight); //Toolbar Configurations SetSupportActionBar(toolbar); SupportActionBar.Title = null; //Spinner tagSpinner.Adapter = new TagsAdapter(this, Android.Resource.Layout.SimpleListItem1, NekosLife.Instance); tagSpinner.ItemSelected += (o, e) => { if (Settings.Instance.GenerateNewImageOnTagChange) { imageStore.Tag = SelectedTag; Toast.MakeText(this, $"Selected '{SelectedTag}'", ToastLength.Short).Show(); //GetNextImage(); } }; bool infoButtonIsUp = false; //Request image download vvv imagePanel.LongClick += (o, e) => { if (!infoButtonIsUp) { infoButtonIsUp = true; imageInfoButton.Animate().TranslationY(-100); Task.Run(() => { Thread.Sleep(3000); RunOnUiThread(() => { imageInfoButton.Animate().TranslationY(PhoneHeight); infoButtonIsUp = false; }); }); } }; imageInfoButton.Click += (o, e) => { if (imagePanel.Drawable == null) { Toast.MakeText(this, "No Images Were Found!", ToastLength.Short).Show(); return; } Android.App.AlertDialog.Builder aDialog; aDialog = new Android.App.AlertDialog.Builder(this); aDialog.SetTitle("Image Options"); aDialog.SetPositiveButton("Download Image", delegate { Bitmap image = imageStore.GetImage(); string path = Android.Provider.MediaStore.Images.Media.InsertImage(ContentResolver, image, ImageName, "A neko from NekoViewer app"); if (path == null) { Toast.MakeText(this, "Couldn't download image", ToastLength.Short).Show(); return; } Toast.MakeText(this, $"Downloaded {ImageName}!", ToastLength.Short).Show(); NotificationController.CreateDownloadNotification(this, "Download Completed!", ImageName, path, image); }); aDialog.SetNeutralButton("Set As Wallpaper", delegate { WallpaperManager.GetInstance(this).SetBitmap(imageStore.GetImage()); Toast.MakeText(this, "Wallpaper has been applied!", ToastLength.Short).Show(); }); aDialog.Show(); }; //Buttons Functions nextImageButton.LongClick += (o, e) => { Android.App.AlertDialog.Builder aDialog; aDialog = new Android.App.AlertDialog.Builder(this); aDialog.SetTitle("Choose An Option"); aDialog.SetNegativeButton("Auto Mode", delegate { AutoSlideEnabled = !AutoSlideEnabled; Toast.MakeText(this, $"Auto Mode Is '{AutoSlideEnabled.ToString()}'", ToastLength.Short).Show(); DoAutoSlide(); }); aDialog.SetPositiveButton("Last Image", delegate { if (loading || downloading || AutoSlideEnabled) { Toast.MakeText(this, "An Image Is Being Downloaded or Loading Please Be Patient", ToastLength.Short).Show(); return; } Toast.MakeText(this, "Last image", ToastLength.Short).Show(); loading = true; imagePanel.Animate().TranslationX(-PhoneWidth); Task.Run(() => { imageStore.GotoLast(); Fix(); RunOnUiThread(() => { ReloadImagePanel(() => { CheckPreviousImageButton(); imagePanel.TranslationX = PhoneWidth; imagePanel.Animate().TranslationX(0); }); }); loading = false; }); }); aDialog.Show(); }; nextImageButton.Click += (o, e) => { if (AutoSlideEnabled) { return; } GetNextImage(); }; previousImageButton.Click += (o, e) => { if (AutoSlideEnabled) { return; } GetPreviousImage(); }; Settings.Instance.AnimationsEnabled.OnChange += delegate { //Do something to disable system animations }; previousImageButton.Visibility = ViewStates.Invisible; }