本文整理匯總了Java中android.support.wearable.watchface.CanvasWatchFaceService類的典型用法代碼示例。如果您正苦於以下問題:Java CanvasWatchFaceService類的具體用法?Java CanvasWatchFaceService怎麽用?Java CanvasWatchFaceService使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
CanvasWatchFaceService類屬於android.support.wearable.watchface包,在下文中一共展示了CanvasWatchFaceService類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: drawViewModelOnCanvas
import android.support.wearable.watchface.CanvasWatchFaceService; //導入依賴的package包/類
public void drawViewModelOnCanvas(final WatchFaceViewModel viewModel, final Canvas canvas, final Rect bounds, final CanvasWatchFaceService.Engine engine) {
// draw background
backgroundPaint.setColor(engine.isInAmbientMode() ? ambientBgColor : interactiveBgColor);
canvas.drawRect(0, 0, bounds.width(), bounds.height(), backgroundPaint);
// draw time
int baseX = bounds.centerX();
int baseY = bounds.centerY();
baseY -= distanceHourMinute*2;
Rect hourBounds = new Rect();
timePaint.getTextBounds(viewModel.hourString, 0, viewModel.hourString.length(), hourBounds);
Rect minuteBounds = new Rect();
timePaint.getTextBounds(viewModel.minuteString, 0, viewModel.minuteString.length(), minuteBounds);
Rect bitcoinPriceBounds = new Rect();
bitcoinPricePaint.getTextBounds(viewModel.bitcoinPriceString, 0, viewModel.bitcoinPriceString.length(), bitcoinPriceBounds);
int timeX = baseX - minuteBounds.width() / 2;
float hourY = baseY - distanceHourMinute / 2;
float minuteY = baseY + minuteBounds.height() + distanceHourMinute / 2;
float bitcoinIconX = baseX - (bitcoinPriceBounds.width() + bitcoinIconSize) / 2;
canvas.drawText(viewModel.hourString, timeX, hourY, timePaint);
canvas.drawText(viewModel.minuteString, timeX, minuteY, timePaint);
// draw bitcoin price
float magicalOffsetToAlignTextWithIcon = distanceHourMinute / 2;
int baseYPrice = bounds.bottom;
baseYPrice -= distanceHourMinute*2;
canvas.drawBitmap(bitcoinIcon, bitcoinIconX, baseYPrice - bitcoinIconSize * 2 + magicalOffsetToAlignTextWithIcon, new Paint());
canvas.drawText(viewModel.bitcoinPriceString, bitcoinIconX + bitcoinIconSize, baseYPrice - bitcoinIconSize, bitcoinPricePaint);
}
示例2: onCreateEngine
import android.support.wearable.watchface.CanvasWatchFaceService; //導入依賴的package包/類
@Override
public CanvasWatchFaceService.Engine onCreateEngine() {
return new Engine();
}
示例3: WatchFaceTimer
import android.support.wearable.watchface.CanvasWatchFaceService; //導入依賴的package包/類
public WatchFaceTimer(CanvasWatchFaceService.Engine engine, Storage storage, GoogleApiClient googleApiClient) {
this.engine = engine;
this.storage = storage;
this.googleApiClient = googleApiClient;
}