Android dynamic bubbles in appearance

Can anyone make a dynamic bubble on an Android layout that can be clicked.

My designer thought the screen below [! [I am all bubble - this is a set of tasks assigned to the user. The bubble label changes according to the task] [1]] [1]

According to my project requirement, the color and radius will change according to api answer.

Can you offer any demo or example. I googled, but I can not find the answer for this. Please help me complete this.

+3
source share
2 answers

As soon as one answer has already been sent, I also tried for you. I hope you also get help from us:

public class BubbleBackgroundDemoActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); View view = new CustomView(this); // RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(this.getWidth(), // ViewGroup.LayoutParams.MATCH_PARENT); // view.setLayoutParams(lp); setContentView(view); } public class CustomView extends View { private Paint paint; int screenWidth, screenHeight; public CustomView(Context context) { super(context); DisplayMetrics displaymetrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); screenWidth = displaymetrics.widthPixels; screenHeight = displaymetrics.heightPixels; // create the Paint and set its color paint = new Paint(); paint.setColor(Color.GRAY); } @Override protected void onDraw(Canvas canvas) { canvas.drawColor(Color.BLUE); canvas.drawCircle(200, 200, 100, paint); canvas.drawCircle(screenWidth-200, 200, 100, paint); canvas.drawCircle(screenWidth/2, screenHeight/2, 300, paint); canvas.drawCircle(screenWidth-200, screenHeight-200, 100, paint); canvas.drawCircle(200, screenHeight-200, 100, paint); } } } 
+1
source

This is how the created circle is configured, you can link to various links to create a circle on the canvas dynamically

 public class CustomView extends View { private Paint paint; public CustomView(Context context) { super(context); // create the Paint and set its color paint = new Paint(); paint.setColor(Color.GRAY); } @Override protected void onDraw(Canvas canvas) { canvas.drawColor(Color.BLUE); canvas.drawCircle(200, 200, 100, paint); } } public class MainActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(new CustomView(this)); } } 
+1
source

Source: https://habr.com/ru/post/975610/


All Articles