日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術文章
文章詳情頁

Android 滑動Scrollview標題欄漸變效果(仿京東toolbar)

瀏覽:218日期:2022-06-06 10:25:47

Scrollview標題欄滑動漸變

仿京東樣式(上滑顯示下滑漸變消失)

Android 滑動Scrollview標題欄漸變效果(仿京東toolbar)

Android 滑動Scrollview標題欄漸變效果(仿京東toolbar)

/** * @ClassName MyScrollView * @Author Rex * @Date 2021/1/27 17:38 */public class MyScrollView extends ScrollView { private TranslucentListener mTranslucentListener; public void setTranslucentListener(TranslucentListener translucentListener) { this.mTranslucentListener = translucentListener; } public MyScrollView(Context context) { this(context, null); } public MyScrollView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); if (mTranslucentListener != null) { //ScrollView滑出高度 int scrollY = getScrollY(); //屏幕高度 int screenHeight = getContext().getResources().getDisplayMetrics().heightPixels; //有效滑動距離為屏幕2分之一 // alpha = 滑動高度/(screenHeight/3f) if (scrollY <= screenHeight / 2f) { Log.d('>>>>>>>>>', 'ScrollView劃出高度:' + scrollY); Log.d('>>>>>>>>>', '屏幕高度:' + screenHeight); Log.d('>>>>>>>>>', '漸變值:' + (0 + scrollY / (screenHeight / 4f))); // 漸變的過程 1~0 mTranslucentListener.onTranslucent(0 + scrollY / (screenHeight /4f)); } } }}

Activity 設置

public class ToolbarActivity extends AppCompatActivity implements TranslucentListener { private Toolbar mToolBar; private MyScrollView mScrollView; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_toobar); mToolBar = findViewById(R.id.id_toolbar); mScrollView = findViewById(R.id.id_scrollView); //初始化漸變為0 mToolBar.setAlpha(0); //設置漸變回調 mScrollView.setTranslucentListener(this); } @Override public void onTranslucent(float alpha) { mToolBar.setAlpha(alpha); }}

漸變回調接口

/** * @ClassName TranslucentListener * @Author rex * @Date 2021/1/27 17:38 */public interface TranslucentListener { /** * 透明度的回調監聽 * * @param alpha 0~1 透明度 */ public void onTranslucent(float alpha);}

布局文件

<RelativeLayout xmlns:android='http://schemas.android.com/apk/res/android' xmlns:app='http://schemas.android.com/apk/res-auto' android:layout_width='match_parent' android:layout_height='match_parent'> <com.rex.rxhttpdemo.MyScrollView android: android:layout_width='match_parent' android:layout_height='match_parent' android:clipChildren='false' android:clipToPadding='false' > <LinearLayout android:layout_width='match_parent' android:layout_height='match_parent' android:orientation='vertical'> <Button android: android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button0' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button1' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button2' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button3' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button4' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button5' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button5' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button5' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button5' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button5' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button5' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button5' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button5' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> <Button android:layout_width='match_parent' android:layout_height='match_parent' android:text='Button' /> </LinearLayout> </com.rex.rxhttpdemo.MyScrollView> <androidx.appcompat.widget.Toolbar android: android:layout_width='match_parent' android:layout_height='wrap_content' android:background='@color/colorAccent' app:title='title' /></RelativeLayout>

下滑顯示上滑漸變消失

/** * @ClassName MyScrollView * @Author Rex * @Date 2021/1/27 17:38 */public class MyScrollView extends ScrollView { private TranslucentListener mTranslucentListener; public void setTranslucentListener(TranslucentListener translucentListener) { this.mTranslucentListener = translucentListener; } public MyScrollView(Context context) { this(context, null); } public MyScrollView(Context context, AttributeSet attrs) { this(context, attrs, 0); } public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr) { this(context, attrs, defStyleAttr, 0); } public MyScrollView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); } @Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); if (mTranslucentListener != null) { //ScrollView滑出高度 int scrollY = getScrollY(); //屏幕高度 int screenHeight = getContext().getResources().getDisplayMetrics().heightPixels; //有效滑動距離為屏幕2分之一 // alpha = 滑動高度/(screenHeight/3f) if (scrollY <= screenHeight / 2f) { Log.d('>>>>>>>>>', 'ScrollView劃出高度:' + scrollY); Log.d('>>>>>>>>>', '屏幕高度:' + screenHeight); Log.d('>>>>>>>>>', '漸變值:' + (1 - scrollY / (screenHeight / 4f))); // 漸變的過程 1~0 mTranslucentListener.onTranslucent(1 - scrollY / (screenHeight /4f)); } } }}

注意: 這里只是更改了 mTranslucentListener.onTranslucent 里的 漸變值

Activty 里 把初始化 mToolBar.setAlpha(0); 去掉

XML

<com.rex.rxhttpdemo.MyScrollView android: android:layout_width='match_parent' android:layout_height='match_parent' android:clipChildren='false' android:clipToPadding='false' android:paddingTop='?attr/actionBarSize' > </com.rex.rxhttpdemo.MyScrollView>

xml 加入 paddingtop .

注意:android:clipChildren=“false”android:clipToPadding='false'這倆個屬性 如果不加會有留白

到此這篇關于Android 滑動Scrollview標題欄漸變效果(仿京東toolbar)的文章就介紹到這了,更多相關Android 滑動Scrollview標題欄漸變內容請搜索好吧啦網以前的文章或繼續瀏覽下面的相關文章希望大家以后多多支持好吧啦網!

標簽: 京東
相關文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
国产一级久久| 国产精品丝袜xxxxxxx| 日韩影院在线观看| 亚洲午夜久久久久久尤物 | av亚洲一区二区三区| 四虎国产精品免费观看| 成年男女免费视频网站不卡| 精品美女视频| av日韩中文| 日韩精品欧美激情一区二区| 欧美黄色一区二区| 精品久久国产一区| а√天堂中文在线资源8| 黑人精品一区| 日韩不卡视频在线观看| 久久九九99| 黄色亚洲免费| 午夜亚洲福利在线老司机| 免费观看在线综合色| 日本vs亚洲vs韩国一区三区二区| 偷拍亚洲精品| 美女在线视频一区| 国产网站在线| 在线国产一区二区| 亚洲毛片网站| 国产欧美精品| 四虎8848精品成人免费网站| 91精品婷婷色在线观看| 亚洲综合精品四区| 日本成人手机在线| 国产一区二区久久久久| 精品捆绑调教一区二区三区| 播放一区二区| 视频一区二区中文字幕| 91成人小视频| 中文字幕在线视频久| 激情五月综合网| 亚洲精品自拍| 国产精品国产三级国产在线观看| 日韩在线不卡| 亚洲高清影视| 91p九色成人| 不卡一二三区| 日韩中文字幕1| 久久免费影院| 亚洲资源av| 麻豆精品av| 红桃视频国产精品| 国产精品久久久久久久久久白浆| 91欧美在线| 免费在线观看成人| 国产精品大片免费观看| 韩国三级一区| 亚洲精品在线a| 国产精品黑丝在线播放| 欧美日韩国产一区二区三区不卡 | 99国产精品视频免费观看一公开| 日韩欧美另类中文字幕| 热三久草你在线| 蜜臀av性久久久久蜜臀aⅴ流畅| 国产精品亚洲综合色区韩国| 四虎4545www国产精品| 亚洲精品自拍| 亚洲天堂1区| 欧美在线日韩| 午夜国产欧美理论在线播放| 国产午夜精品一区在线观看| 亚洲www啪成人一区二区| 亚洲精品日韩久久| 欧美香蕉视频| 国产精品丝袜在线播放| 99国产精品久久久久久久| 精品国产18久久久久久二百| 免费人成精品欧美精品| 黄色在线网站噜噜噜| 亚洲精品动态| 欧美日韩中文一区二区| 欧美精品aa| 免费在线观看视频一区| 亚洲成人一区在线观看| 国产精品尤物| 亚洲在线一区| 日韩精品午夜| 久久影院资源站| 亚洲免费毛片| 国产一区日韩欧美| 红杏一区二区三区| 日韩av一区二区三区| 欧美不卡视频| а√天堂8资源在线| 国产精品www994| 天海翼精品一区二区三区| 91精品国产调教在线观看| 成人亚洲精品| 欧美国产不卡| 欧美一区影院| 亚洲乱码一区| 99国产一区| 99精品在线观看| 国产成人久久精品一区二区三区| 亚洲精一区二区三区| 亚洲精品中文字幕乱码| 精品捆绑调教一区二区三区| 精品视频网站| 欧美激情aⅴ一区二区三区| 热久久久久久| 青青草国产精品亚洲专区无| 免费观看在线综合色| 亚洲色诱最新| 婷婷久久一区| 99免费精品| 在线一区av| 91亚洲国产| 精品欧美日韩精品| 欧美国产专区| 麻豆精品蜜桃视频网站| 久久国产视频网| 青青国产精品| 国产亚洲一区二区三区啪| 亚洲精品美女91| 日韩有吗在线观看| 日韩精品一级中文字幕精品视频免费观看| 亚洲高清激情| 激情欧美丁香| 激情五月综合网| 亚洲一区二区三区四区五区午夜| 精品中文字幕一区二区三区av| 久久影院一区| 国产91一区| 欧美91视频| 亚洲免费激情| 99国产精品视频免费观看一公开 | 黄色aa久久| 久久天堂成人| 免费观看不卡av| 五月婷婷亚洲| 在线国产一区| 在线精品一区| 日本不卡一区二区三区| 日韩av在线免费观看不卡| 欧美啪啪一区| 欧美激情麻豆| 福利片在线一区二区| 岛国av在线播放| 99久久夜色精品国产亚洲1000部| 欧美日韩国产高清电影| 天使萌一区二区三区免费观看| 99pao成人国产永久免费视频 | 欧美日韩国产在线一区| 每日更新成人在线视频| 日本精品另类| 麻豆视频一区二区| 日韩大片在线观看| 国产一区日韩一区| 中文字幕日本一区二区| 国产亚洲精品美女久久久久久久久久| 国产日韩欧美高清免费| 久久久国产精品网站| 日韩欧美精品| 欧美日韩国产一区二区三区不卡 | 欧美日韩亚洲一区二区三区在线 | 伊人久久成人| 亚洲美女91| 麻豆成人综合网| 高清不卡亚洲| 一区在线观看| 国产亚洲一区二区三区啪| 成年男女免费视频网站不卡| 欧美 日韩 国产精品免费观看| 一区二区三区国产在线| 国产精品分类| 日韩精品一区二区三区免费观看| 狠狠久久婷婷| 国产欧美69| 日韩高清中文字幕一区二区| 鲁大师成人一区二区三区 | 青青青国产精品| 色婷婷亚洲mv天堂mv在影片| 免费观看不卡av| 国产精品三级| 欧美午夜精彩| 日本强好片久久久久久aaa| 国产v日韩v欧美v| 亚洲精品九九| 亚洲精品在线影院| 日韩精品亚洲专区在线观看| 国产白浆在线免费观看| 亚洲免费专区| 亚洲成av人片一区二区密柚| 日韩精品一区二区三区中文| 91偷拍一区二区三区精品| 蜜桃一区二区三区在线| 国产精品黄色片| 亚洲免费黄色| 国产成人久久精品一区二区三区| 制服诱惑一区二区| 精品久久久网| 日韩精品久久理论片| 久久久成人网| 日韩福利在线观看|