2017-06-12 17 views
-1

I was following this tutorialComplicationDrawableを使用して時計の面に合併症を追加する方法について私が把握できないことは、コンテンツに応じてComplicationDrawableをどのようにして返すのですか?たとえば、下部の複雑さのデータ型がComplicationData.TYPE_LONG_TEXTの場合、テキストを調整するためにComplicationDrawableを広げるにはどうすればよいですか?どのように合併症を適応させるのですか?

Here is my code for how I'm drawing the bounds for the complications

私はこの場所の例を見つけることができないので、おそらくそれは不可能です。

答えて

1

コードに必要なものはすべて既に用意されています。欠けているのは、合併症の種類に基づいて境界を設定することだけです。これが私のやり方です:

// Create a ComplicationDrawable object, and give it a Context. 
ComplicationDrawable complicationDrawable = new ComplicationDrawable(); 
complicationDrawable.setContext(context); 

// Set the ComplicationData from the onComplicationDataUpdate(int id, ComplicationData data) callback in your WatchFaceService.Engine class. 
complicationDrawable.setComplicationData(data); 

// Set the bounds based on the current complication type. 
Rect bounds = new Rect(); 
if (data.getType() == ComplicationData.TYPE_LONG_TEXT) { 
    bounds.set(getLongTextBounds()); 
} else { 
    bounds.set(getShortTextBounds()); 
} 
complicationDrawable.setBounds(bounds); 

// Set all other customization options, and draw the ComplicationDrawable to your canvas. 
関連する問題