繁体   English   中英

Android表盘:如何知道是否显示窥视卡以及显示到什么高度?

[英]Android watchface: how to know if a peek card is shown and to what height?

一个人如何调用显示卡的信息以及显示卡的高度。

我正在使用平衡的三元时钟,并且我想根据卡来调整面部大小。

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

// 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; 

您是否在询问偷看卡 如果是这样,则在该链接中记录获取其尺寸的信息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM