Android custom view circle, drag circle and drag with finger effect
Simply customizing a circle is very simple. It only takes a few steps to drag the circle to add and realize the touch event
Several bugs I encountered in the first custom view circle:
1. If you drag a circle, the width and height of the custom circle set in the XML is the size of the space it can move, not the size of the circle control. If you define 100dp, if you drag it more than 100dp, the circle will be invisible. As shown below, if you want to move on the whole screen, match the width and height directly_ Just the parent attribute
2. I'm defining the match attribute_ An error will be reported when the parent is running, but no method is used. Just wait patiently for a while... Maybe studio didn't compile it in time
Let's start writing code: first, simply create a circle, create a class, inherit view, and implement OnDraw method
Name of self defined view class in XML:
Once a circle is created, it can be run directly. There is no need to change anything in manactivity
The following is the function of adding and dragging circles. It is very simple to realize touch monitoring. There are very few codes as follows:
summary
The above is the Android custom view circle, drag circle and drag with finger effect introduced by Xiaobian. I hope it will be helpful to you. If you have any questions, please leave me a message and Xiaobian will reply to you in time. Thank you very much for your support for the programming tips website!