0
J'ai ajouté une vue personnalisée dans une disposition relative et je veux un bitmap de cette disposition relative contenant le texte de la courbe et je veux stocker cette image dans l'image.Comment convertir une vue personnalisée contenant du texte courbe en bitmap?
' RelativeLayout relativeLayout;
privé ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
relativeLayout= (RelativeLayout) findViewById(R.id.rel);
imageView= (ImageView) findViewById(R.id.img1);
Circle circle=new Circle(MainActivity.this);
relativeLayout.addView(circle);
}
public class Circle extends View {
Paint paint = new Paint();
Path path = new Path();
private static final String s = "Hello world example";
public Circle(Context context) {
super(context);
paint.setColor(Color.BLACK);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(2);
paint.setAntiAlias(true);
paint.setTextSize(30);
}
public void onDraw(Canvas c) {
c.rotate(180, getWidth()/2, getHeight()/2);
path.addCircle(getWidth()/2, getHeight()/2, 90, Path.Direction.CW);
c.drawTextOnPath(s, path, 0, 10, paint);
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
}
}`'