Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does Android achieve the hidden effect of imitating NetEase's news picture details?

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the relevant knowledge of "how to achieve Android to imitate NetEase news picture details slide hiding effect", the editor shows you the operation process through an actual case, the method of operation is simple and fast, and practical. I hope that this article "how to achieve Android imitation NetEase news picture details slide hiding effect" article can help you solve the problem.

Effect picture:

Instance code

Public class InfoTextView extends AutoRelativeLayout {private Context context; private int lastY; private int offY; private int MIN_HEIGHT = 600; public InfoTextView (Context context) {super (context); this.context = context; init ();} public InfoTextView (Context context, AttributeSet attrs) {super (context, attrs); this.context = context; init ();} public InfoTextView (Context context, AttributeSet attrs, int defStyle) {super (context, attrs, defStyle); this.context = context; init () } private void init () {View root = inflate (context, R.layout.ad_detail_text_layout, this);} @ Override public boolean onInterceptTouchEvent (MotionEvent ev) {return true;} @ Override public boolean onTouchEvent (MotionEvent event) {return true;} @ Override public boolean dispatchTouchEvent (MotionEvent ev) {boolean isConsume = false; int y = (int) ev.getY (); switch (ev.getAction ()) {case MotionEvent.ACTION_DOWN: isConsume = true; lastY = y Break; case MotionEvent.ACTION_MOVE: offY = y-lastY; int [] screenSize = ScreenUtils.getScreenSize (context, false); if (getTop () > = (screenSize [1]-MIN_HEIGHT)) {break } / / Log.d ("yzk", "y" + y + "getTop" + getTop () / + "getBottom" + getBottom () / / + "screenSize [1]-getMeasuredHeight" + (screenSize [1]-getMeasuredHeight ()) / + "screenSize [1]-MIN_HEIGHT" + (screenSize [1]-MIN_HEIGHT)); if ((offY > 0 & getTop ())

< screenSize[1] - MIN_HEIGHT) || offY < 0 && getTop() >

ScreenSize [1]-getMeasuredHeight () {layout (getLeft (), getTop () + offY, getRight (), getBottom () + offY);} break; case MotionEvent.ACTION_UP: break;} return isConsume | | super.dispatchTouchEvent (ev);}} this is the end of the content about "how Android achieves the hiding effect of news pictures imitated by NetEase". Thank you for reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report