Android表盘:如何知道是否显示了一张偷看卡以及高度是多少?

时间:2016-07-16 17:54:08

标签: android wear-os android-cards watchface

如何调用显示卡片的信息以及显示卡片的高度。

我正在制作一个平衡的三元闹钟,我想根据卡片调整脸部的大小。

编辑:我找到了解决方案。

// detect the height of a card. And call resizers.
// baseLedge is the default bottom of the watch
// tallness is the height of the display
// tallable is the portion of the screen height offered to the face.
// ledge is the adjusted bottom of the watch
// ledgeSpace is a desired margin above the ledge
// puff is the ratio of the adjusted display to the standard display
// puffer() is a module (or method or whatever the correct term is) that applies the resizing.
    // no clue what the Override wrapper does or how it work.   
    @Override
    // Rect -> none
    public void onPeekCardPositionUpdate(Rect bounds) {
        super.onPeekCardPositionUpdate(bounds);
        if (!bounds.equals(mCardBounds)) {
            mCardBounds.set(bounds);
            if (bounds.top == 0){bounds.top = (int)tallness;}
            if (bounds.top < baseLedge || ledge != baseLedge) {
                ledge = Math.min(bounds.top, baseLedge);
                puff = (ledge - dispTop -) / tallable; 
                if (puff < (float).25) {puff = (float).25; }
                puffer ();
            }
            invalidate(); // redraw screen without updating time.
        }
    }

注意:制作一个标志并找到以下代码可放入onPeekCardPositionUpdate()的高度

yesCard = bounds.top != (int)0; // boolean that will be true if a card is showing.
cardHeight = (float)bounds.top; 

1 个答案:

答案 0 :(得分:0)

您在询问peek cards吗?如果是这样,那么在该链接上记录获取其尺寸。