当前位置:网站首页>Modify a value to make Scrollview and listview elastic and APK volume optimized

Modify a value to make Scrollview and listview elastic and APK volume optimized

2022-01-15 02:06:33 mb61ab4a9335a30

First look at the code :

[java]?[view plain]( )[copy]( )[print]( )[?]( ) stay CODE Check the code chip on  Derived from my code chip

  1. package?com.xys.flexible;??

  2. import?android.content.Context;??

  3. import?android.util.AttributeSet;??

  4. import?android.util.DisplayMetrics;??

  5. import?android.widget.ScrollView;??

  6. public?class?FlexibleScrollView?extends?ScrollView?{??

  7. ????private?Context?mContext;??

  8. ????private?static?int?mMaxOverDistance?=?50;??

  9. ????public?FlexibleScrollView(Context?context,?AttributeSet?attrs,??

  10. ????????????int?defStyleAttr)?{??

  11. ????????super(context,?attrs,?defStyleAttr);??

  12. ????????this.mContext?=?context;??

  13. ????????initView();??

  14. ????}??

  15. ????public?FlexibleScrollView(Context?context,?AttributeSet?attrs)?{??

  16. ????????super(context,?attrs);??

  17. ????????this.mContext?=?context;??

  18. ????????initView();??

  19. ????}??

  20. ????public?FlexibleScrollView(Context?context)?{??

  21. ????????supe

《Android Summary of learning notes + Latest mobile architecture video + Big Android interview questions + Project actual combat source code handout 》

【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 Open source sharing of complete information

r(context);??

  1. ????????this.mContext?=?context;??

  2. ????????initView();??

  3. ????}??

  4. ????private?void?initView()?{??

  5. ????????DisplayMetrics?metrics?=?mContext.getResources().getDisplayMetrics();??

  6. ????????float?density?=?metrics.density;??

  7. ????????mMaxOverDistance?=?(int)?(density?*?mMaxOverDistance);??

  8. ????}??

  9. [email protected]??

  10. ????protected?boolean?overScrollBy(int?deltaX,?int?deltaY,?int?scrollX,??

  11. ????????????int?scrollY,?int?scrollRangeX,?int?scrollRangeY,??

  12. ????????????int?maxOverScrollX,?int?maxOverScrollY,?boolean?isTouchEvent)?{??

  13. ????????return?super.overScrollBy(deltaX,?deltaY,?scrollX,?scrollY,??

  14. ????????????????scrollRangeX,?scrollRangeY,?maxOverScrollX,?mMaxOverDistance,??

  15. ????????????????isTouchEvent);??

  16. ????}??

  17. }??

In fact, although we have rewritten ScrollView( perhaps ListView), But only one value of one of its methods has been changed !

Also is to overScrollBy Medium maxOverScrollY It's changed to our own values .

Test layout :

[html]?[view plain]( )[copy]( )[print]( )[?]( ) stay CODE Check the code chip on  Derived from my code chip

  1. <RelativeLayout?xmlns:android\=" http://schemas.android.com/apk/res/android"??

  2. ????xmlns:tools\=" http://schemas.android.com/tools"??

  3. ????android:layout_width\="match_parent"??

  4. ????android:layout_height\="match_parent"??

  5. ????android:paddingBottom\="@dimen/activity_vertical_margin"??

  6. ????android:paddingLeft\="@dimen/activity_horizontal_margin"??

  7. ????android:paddingRight\="@dimen/activity_horizontal_margin"??

Last

Actually Android There are so many knowledge points in development , There are still so many things to ask about in the interview . So there's no other trick to an interview , It depends on how well you are prepared for these knowledge points .so, When you go out for an interview, you should first see which stage you have reviewed .

Shared above tencent 、 headlines 、 Ali 、 Meituan 、 Byte skipping and so on 2019-2021 High frequency interview questions in , Bloggers also organized these technical points into videos and PDF( In fact, it took a lot more energy than expected ), contain The context of knowledge + A lot of details , Due to limited space , The above is just a part of the picture .

【Android Mind map ( The skill tree )】

Knowledge system is not perfect ? And here's what's sorted out Android Mind map for advanced learning , Here's a direction for your reference .

 Modify a value , Give Way ScrollView、ListView Full of flexibility ,apk Volume optimization

【Android Advanced architecture video learning resources 】

This article has been  CODING Open source project :《Android Summary of learning notes + Mobile architecture video + The real interview question of Dachang + Project source code 》 Included

版权声明
本文为[mb61ab4a9335a30]所创,转载请带上原文链接,感谢
https://chowdera.com/2021/12/202112122212513471.html

随机推荐