Android : Draw Circle With Text Inside

前端 未结 5 755
闹比i
闹比i 2020-12-01 12:29

I need to draw three circles in my fragment ,the circles differ in size, I refer this link The result i obtained is this

5条回答
  •  被撕碎了的回忆
    2020-12-01 12:40

    Try this code to create dynamically circle with textview

    RelativeLayout main_rel_layout = findViewById(R.id.main_rel_layout);
    TextView textView = new TextView(this);
    RelativeLayout relativeLayout = new RelativeLayout(this);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    params.addRule(RelativeLayout.CENTER_IN_PARENT);
    textView.setText("Hello ");
    textView.setTextSize(100);
    textView.setLayoutParams(params);
    textView.setGravity(Gravity.CENTER);
    
    final FrameLayout frameLayout = new FrameLayout(this);
    FloatingActionButton floatingActionButton = new FloatingActionButton(this);
    floatingActionButton.setCustomSize(400);
    frameLayout.addView(floatingActionButton);
    
    relativeLayout.addView(frameLayout);
    relativeLayout.addView(textView);
    main_rel_layout.addView(relativeLayout);
    

提交回复
热议问题