source: advance-wars/src/com/example/gui/Text.java@ 205f525

Last change on this file since 205f525 was 205f525, checked in by dportnoy <devnull@…>, 14 years ago

Added some buttons to the main menu. Added a new package to the project to make gui creation easier.

  • Property mode set to 100644
File size: 609 bytes
Line 
1package com.example.gui;
2
3import android.graphics.Canvas;
4import android.graphics.Paint;
5
6public class Text extends GUIObject {
7 private String text;
8 private Paint textPaint;
9 private float vOffset;
10
11 public Text(String newText, int newX, int newY, int newWidth, int newHeight, Paint textPaint) {
12 super(newX, newY, newWidth, newHeight, null);
13
14 this.textPaint = textPaint;
15 text = newText;
16 vOffset = -(textPaint.getFontMetrics().ascent+textPaint.getFontMetrics().descent)/2;
17 }
18
19 public void draw(Canvas c) {
20 c.drawText(text, x+width/2, y+height/2+vOffset, textPaint);
21 }
22}
Note: See TracBrowser for help on using the repository browser.