List of usage examples for android.graphics Paint getFontSpacing
public float getFontSpacing()
From source file:org.cicadasong.samples.nextbuses.NextBuses.java
protected void onDraw(Canvas canvas) { // Set font for heading Paint paint = isWidget() ? metawatch5px : metawatch7px; int x = 2;/*from ww w .j av a 2 s . c o m*/ int y = 2 + (int) -paint.ascent(); canvas.drawText("Next buses at...", x, y, paint); y += (int) paint.descent() + 2; // Set font for stop name paint = isWidget() ? metawatch7px : metawatch11px; y += (int) -paint.ascent(); canvas.drawText(stopName, x, y, paint); y += (int) paint.descent() + 2; // Set font for "body" paint = isWidget() ? metawatch5px : default10pt; y += (int) -paint.ascent(); if (inInitialFetch) { canvas.drawText("Fetching...", x, y, paint); } else if (predictions == null) { canvas.drawText("Network Error", x, y, paint); } else if (isWidget()) { String singleLineResult = ""; List<Prediction> allPredictions = predictions.getAllPredictions(); StringBuilder resultBuilder = new StringBuilder(); for (Prediction prediction : allPredictions) { if (resultBuilder.length() > 0) { resultBuilder.append(" "); } resultBuilder.append(prediction.route); resultBuilder.append("~"); resultBuilder.append(prediction.minutes); resultBuilder.append("m"); } singleLineResult = resultBuilder.toString(); canvas.drawText(singleLineResult, x, y, paint); } else { // We're in app mode, so we have more screen space to work with for (String route : predictions.getRoutes()) { StringBuilder resultBuilder = new StringBuilder(); resultBuilder.append(route); resultBuilder.append(":"); for (Prediction prediction : predictions.getPredictionsForRoute(route)) { resultBuilder.append(" "); resultBuilder.append(prediction.minutes); resultBuilder.append("m"); } canvas.drawText(resultBuilder.toString(), x, y, paint); y += paint.getFontSpacing(); } } }