我必须在所有屏幕的给定图像中的不同点上对齐文本。有没有人可以帮助我实现这个目标?
答案 0 :(得分:0)
使用XML
标记来实现您的UI非常困难,但有Canvas
个方法可以轻松绘制所有基元。
样品:
private Paint circlePaint;
private Paint linePaint;
private Paint textPaint;
private String[] titles;
private float circleRadius;
@Override protected void onDraw(Canvas canvas) {
float height = getHeight();
float width = getWidth();
float circleX;//set initial X depending on width and height of screen
float circleY;//set initial Y
for (int i = 0; i < titles.length; i++) {
String title = titles[i];
canvas.drawCircle(circleX, circleY, circleRadius, circlePaint);
canvas.drawText(title, circleX + circleRadius, circleY, textPaint);
float nextCircleX;//calculate next X coordinate
float nextCircleY;//calculate next Y coordinate
canvas.drawLine(circleX, circleY, nextCircleX, nextCircleY, circlePaint);
circleX = nextCircleX;
circleY = nextCircleY;
}
}