
在Google Play商店应用的第5版中,滚动到内容,按下滚动 *** 作栏,但选项卡已修复以显示在顶部.
这该怎么做?
在滚动之前
滚动后
解决方法:
正如其他人所建议的那样,使用来自:https://github.com/ksoichiro/Android-ObservableScrollView的ObservableScrollVIEw
尝试将工具栏和SlIDingTabStrip放在同一个容器中,然后在用户滚动ObservableScrollVIEw时为该容器设置动画,例如:
<FrameLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" xmlns:tools="http://schemas.androID.com/tools" androID:layout_wIDth="match_parent" androID:layout_height="match_parent" tools:context=".MainActivity"> <com.github.ksoichiro.androID.observablescrollvIEw.ObservableListVIEw androID:ID="@+ID/ListVIEw" androID:layout_height="match_parent" androID:layout_wIDth="match_parent"/> <linearLayout androID:ID="@+ID/toolbarContainer" androID:orIEntation="vertical" androID:elevation="10dp" androID:background="@color/material_deep_teal_200" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content"> <androID.support.v7.Widget.Toolbar androID:ID="@+ID/toolbar" androID:layout_wIDth="match_parent" androID:layout_height="?attr/actionbarSize"/> <!--Placeholder vIEw, your tabstrip goes here--> <VIEw androID:layout_wIDth="wrap_content" androID:layout_height="48dp"/> </linearLayout></FrameLayout>然后,当您重写ObservableScrollVIEwCallbacks时,您可以执行以下 *** 作:
@OverrIDepublic voID onScrollChanged(int scrollY, boolean firstScroll, boolean dragging) { toolbarContainer.animate().cancel(); int scrollDelta = scrollY - oldScrollY; oldScrollY = scrollY; float currentYTranslation = -toolbarContainer.getTranslationY(); float targetYTranslation = Math.min(Math.max(currentYTranslation + scrollDelta, 0), toolbarHeight); toolbarContainer.setTranslationY(-targetYTranslation);}@OverrIDepublic voID onUpOrCancelMotionEvent(ScrollState scrollState) { float currentYTranslation = -toolbarContainer.getTranslationY(); int currentScroll = ListVIEw.getCurrentScrollY(); if (currentScroll < toolbarHeight) { toolbarContainer.animate().translationY(0); } else if (currentYTranslation > toolbarHeight /2) { toolbarContainer.animate().translationY(-toolbarHeight); } else { toolbarContainer.animate().translationY(0); }}onUpOrCancelMotionEvent的内容是为容器设置动画,以防止工具栏只显示/隐藏一半.
这是一个演示视频,仅供参考:https://drive.google.com/file/d/0B7TH7VeIpgSQSzZER1NneWpYa1E/view?usp=sharing
总结以上是内存溢出为你收集整理的android – 动画如何隐藏ActionBar并保持标签?全部内容,希望文章能够帮你解决android – 动画如何隐藏ActionBar并保持标签?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)