I reinstalled the compiler today, but it was a big deal. I just knew where the problem was.
Okay, let’s talk about serious matters. I have no contact with iOS development and don’t know much about it. After Baidu for a long time, it’s almost the UIScrollView. If it is wrong, please give evidence. What's the specific effect? I just looked at the iPhone's iPhone with my friend's iPhone. The iPhone settings interface is to pull down the first list and continue to scroll. The same is true for pulling up. But Android doesn't seem to have this kind of situation.
I call this effect a scrollview with no limits.
Here is the source code:
First of all, the most important thing is to determine whether the current view is empty. It seems that there is no difference whether your empty view is scrolled or not, except that the scrollview of Android 5.0 comes with that kind of arc. It seems that there is no soft use~~~
//The view can be scrolled if it is not empty protected void onFinishInflate() { if (getChildCount() > 0) { childview = getChildAt(0); } }
I just knew this property not long ago, which means that this method is called after all layout rendering is completed.
I have attached the commonly used methods of view here. You can study it yourself. There are many methods I don’t know.
Common ways to customize Views:
onFinishInflate() fires when all child controls in the View are mapped to XML
onMeasure(int, int) Determines the size of all child elements
onLayout(boolean, int, int, int) fires when the View allocates the size and position of all child elements
onSizeChanged(int, int, int, int) fires when the size of the view changes
Details of the rendering content onDraw(Canvas) view
onKeyDown(int, KeyEvent) Triggered after a key is pressed
onKeyUp(int, KeyEvent) Triggered when a key is pressed and pops up.
onTrackballEvent(MotionEvent) Trackball Event
onTouchEvent(MotionEvent) Touch screen event
onFocusChanged(boolean, int, Rect) Triggered when the View gets or loses focus
onWindowFocusChanged(boolean) fires when the view contained in the window is fetched or lost focus
onAttachedToWindow() fires when view is attached to a window
onDetachedFromWindow() fires when the view leaves the attached window, prompting that the method is the opposite of onAttachedToWindow().
onWindowVisibilityChanged(int) fires when the visible view contained in the window changes
The above are some basic interface callback methods implemented by View. Generally, when we need to deal with the display of canvas, we use the most rewrite onDraw (Canvas).
Next is the ontouch event to determine the effect of displacement and rebound:
if (childview != null) { int action = (); switch (action) { case MotionEvent.ACTION_DOWN: break; case MotionEvent.ACTION_UP: //Judge whether animation is needed if (!()) { animation(); isCount = false; } break; case MotionEvent.ACTION_MOVE: final float DownY = startY; float moveY = (); int distance = (int) (DownY - moveY); if (!isCount) { distance = 0; // It's 0 here. } startY = moveY; if (isNeedMove()) { //top if (()) { ((), (), (), ()); } //bottom ((), () - distance / 2, (), () - distance / 2); } isCount = true; break; }
The following is the animation effect of determining whether scrolling and rebounding is needed.
public void animation() { // Turn on mobile animation TranslateAnimation animation = new TranslateAnimation(0, 0, (), ); (200); (animation); // Set back to normal layout position (, , , ); (); }
public boolean isNeedMove() { int offset = () - getHeight(); int scrollY = getScrollY(); // 0 is the top, the one behind is the bottom if (scrollY == 0 || scrollY == offset) { return true; } return false; }
Okay, a scrollview that can roll, roll, roll, roll, roll without limits will be born. Actually, I don’t think this is very practical, it depends on personal needs. Actually it's quite fun ~
The above UIScrollView example code for Android development imitating iOS is all the content I have shared with you. I hope you can give you a reference and I hope you can support me more.