How to set complexity on the watchman ICON, RANGED_VALUE, SMALL_IMAGE on android wear

I tried to draw an icon on the front of Android, but did not see it on the dial. I am already checking this link. Ref I set the text on the text screen for the TYPE complex text, but it is not set for other types such as ICON, RANGED_VALUE, SMALL_IMAGE, so please suggest.

I need an icon of this type where the red mark is complex.

I need an icon of this type, where is the complexity of the red sign. I used this code to draw text.

if (COMPLICATION_IDS[i] == RIGHT_DIAL_COMPLICATION) {
                        // RIGHT_DIAL_COMPLICATION calculations
                        int offset = (int) ((mWidth / 2) - textWidth) / 2;
                        complicationsX = (mWidth / 2) + offset;
                        canvas.drawText(
                                complicationMessage,
                                0,
                                complicationMessage.length(),
                                complicationsX,
                                mComplicationsY,
                                mComplicationPaint);
                        Log.e("log", "offset==" + offset + "==complicationsX==" + complicationsX);
                        Log.e("log", "mComplicationsY==" + mComplicationsY);

                    }

and use this code for the image but get nothing.

if (COMPLICATION_IDS[i] == LEFT_DIAL_COMPLICATION) {
                        complicationsX = (int) ((mWidth / 2) - textWidth) / 2;

                        Icon icon = complicationData.getIcon();
                        Drawable drawable = icon.loadDrawable(getApplicationContext());
                        if (drawable instanceof BitmapDrawable) {
                            Bitmap bitmap;
                            bitmap = ((BitmapDrawable) drawable).getBitmap();
                            canvas.drawBitmap(bitmap, complicationsX, mComplicationsY, null);
                        }
                    } 
-2
source share
1 answer

, draw:

Icon icon = complicationData.getIcon();
if(icon != null) {
    Drawable drawable = icon.loadDrawable(getApplicationContext());
    if(drawable != null) {
        drawable.setBounds(20, 20, 50, 50); //left, top, right, bottom
        drawable.draw(canvas);
    }
}
0

Source: https://habr.com/ru/post/1666431/


All Articles