當前位置: 首頁>>代碼示例>>Java>>正文


Java CanvasWatchFaceService類代碼示例

本文整理匯總了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);
}
 
開發者ID:tobiasheine,項目名稱:BitcoinWatcher,代碼行數:36,代碼來源:WatchFaceDrawer.java

示例2: onCreateEngine

import android.support.wearable.watchface.CanvasWatchFaceService; //導入依賴的package包/類
@Override
public CanvasWatchFaceService.Engine onCreateEngine() {
    return new Engine();
}
 
開發者ID:jimmykane,項目名稱:Athletica,代碼行數:5,代碼來源:WatchFaceService.java

示例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;
}
 
開發者ID:tobiasheine,項目名稱:BitcoinWatcher,代碼行數:7,代碼來源:WatchFaceTimer.java


注:本文中的android.support.wearable.watchface.CanvasWatchFaceService類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。