本文整理汇总了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;
}