protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_practice_repast); var mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar); mToolbar.NavigationClick += (sender, e) => { Finish(); }; var mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout; if (isFirstEnter) { isFirstEnter = false; mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果 } var recyclerView = FindViewById <RecyclerView>(Resource.Id.recyclerView); recyclerView.SetItemAnimator(new DefaultItemAnimator()); recyclerView.SetLayoutManager(new LinearLayoutManager(this)); //recyclerView.AddItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.Vertical)); mAdapter = new CustomBaseRecyclerAdapter(loadModels(), Resource.Layout.listitem_practive_repast); recyclerView.SetAdapter(mAdapter); mRefreshLayout.SetOnRefreshLoadmoreListener(new CustomOnRefreshLoadmoreListener(this)); //状态栏透明和间距处理 StatusBarUtil.darkMode(this); StatusBarUtil.setPaddingSmart(this, recyclerView); StatusBarUtil.setPaddingSmart(this, mToolbar); StatusBarUtil.setPaddingSmart(this, FindViewById(Resource.Id.blurview)); StatusBarUtil.setMargin(this, FindViewById(Resource.Id.gifview)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_practice_webview); var mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar); mToolbar.NavigationClick += (sender, e) => { Finish(); }; mRefreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout; mRefreshLayout.SetOnRefreshListener(new CustomOnRefreshListener(this)); mRefreshLayout.AutoRefresh();//第一次进入触发自动刷新,演示效果 webView = FindViewById <WebView>(Resource.Id.webView); webView.Settings.JavaScriptEnabled = true; webView.SetWebViewClient(new CustomWebViewClient(this)); //状态栏透明和间距处理 StatusBarUtil.immersive(this); StatusBarUtil.setPaddingSmart(this, webView); StatusBarUtil.setPaddingSmart(this, mToolbar); StatusBarUtil.setMargin(this, FindViewById(Resource.Id.header)); StatusBarUtil.setPaddingSmart(this, FindViewById(Resource.Id.blurview)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_practice_profile); var mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar); mToolbar.NavigationClick += (sender, e) => { Finish(); }; //状态栏透明和间距处理 StatusBarUtil.darkMode(this); StatusBarUtil.setPaddingSmart(this, mToolbar); StatusBarUtil.setPaddingSmart(this, FindViewById(Resource.Id.profile)); StatusBarUtil.setPaddingSmart(this, FindViewById(Resource.Id.blurview)); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.activity_practice_weibo); mToolbar = FindViewById <Toolbar>(Resource.Id.toolbar); mToolbar.NavigationClick += (sender, e) => { Finish(); }; //状态栏透明和间距处理 StatusBarUtil.immersive(this); StatusBarUtil.setPaddingSmart(this, mToolbar); parallax = FindViewById(Resource.Id.parallax); var buttonBar = FindViewById(Resource.Id.buttonBarLayout); var scrollView = FindViewById <NestedScrollView>(Resource.Id.scrollView); var refreshLayout = FindViewById(Resource.Id.refreshLayout) as IRefreshLayout; refreshLayout.SetOnMultiPurposeListener(new CustomSimpleMultiPurposeListener(this)); int lastScrollY = 0; int h = DensityUtil.Dp2px(170); int color = ContextCompat.GetColor(ApplicationContext, Resource.Color.colorPrimary) & 0x00ffffff; scrollView.ScrollChange += (sender, e) => { var scrollX = e.ScrollX; var scrollY = e.ScrollY; if (lastScrollY < h) { scrollY = Math.Min(h, scrollY); mScrollY = scrollY > h ? h : scrollY; buttonBar.Alpha = 1f * mScrollY / h; mToolbar.SetBackgroundColor(new Android.Graphics.Color(((255 * mScrollY / h) << 24) | color)); parallax.TranslationY = mOffset - mScrollY; } lastScrollY = scrollY; }; buttonBar.Alpha = 0; mToolbar.SetBackgroundColor(new Android.Graphics.Color(0)); }
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)); }