Android custom view control to achieve refresh effect
Three ways to get linear inflator
a. LayoutInflater inflater = getLayoutInflater();
b. LayoutInflater localinflater =
(LayoutInflater)context.getSystemService (Context.LAYOUT_INFLATER_SERVICE);
c. LayoutInflater inflater = LayoutInflater.from(context);
The OnDraw method draws, and invalidate refreshes the interface.
design sketch:
Click to change the color
After OnDraw draws the diagram, set the click event for the control, transfer the parameters to the control, and then invalidate the refresh
1. OnDraw draw and add the changecolor method
2. Layout
3. After drawing, set the click event for the control, and then invalidate refresh
As for the problem that custom controls occupy the whole screen, you may need to use layoutparams
The above is the Android custom view control introduced by Xiaobian to achieve the refresh effect. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time!