SoFunction
Updated on 2025-04-07

Android hollow circle and stacking effect implementation code

This article shares the specific codes for Android hollow circles and stacking effects for your reference. The specific content is as follows

package .zidingyiview2;

import ;
import ;
import ;
import ;
import ;
import ;


public class MyView extends View {
 private Context mcontext;
 private Paint mpaint;

 public MyView(Context context) {
  super(context);
 }

 public MyView(Context context, AttributeSet attrs) {
  super(context, attrs);
 }

 public MyView(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);
   = context;
 }

 @Override
 protected void onDraw(Canvas canvas) {
  (canvas);
// Get the screen width and height  float wi = () / 2;
  float he = () / 2;
// Create the first brush  Paint pa = new Paint();
// Color  ();
// Show round edges  (true);
// Set up hollow rings  ();
// Set the ring width  (6);
  Paint pa2 = new Paint();
  ();
  (true);
  Paint pa3 = new Paint();
  ();
  (true);
// What circle to draw  (wi-85, he-85, 80, pa2);
  (wi, he, 100, pa);
  (wi+110, he+110, 120, pa3);
 }
}

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
 xmlns:andro
 xmlns:tools="/tools"
 android:
 android:layout_width="match_parent"
 android:layout_height="match_parent"
 android:paddingBottom="@dimen/activity_vertical_margin"
 android:paddingLeft="@dimen/activity_horizontal_margin"
 android:paddingRight="@dimen/activity_horizontal_margin"
 android:paddingTop="@dimen/activity_vertical_margin"
 tools:context=".">

 <.
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"/>
</RelativeLayout>

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.