【问题标题】:Android watchface: how to know if a peek card is shown and to what height?Android表盘:如何知道是否显示了偷看卡以及显示到什么高度?
【发布时间】:2016-07-16 17:54:07
【问题描述】:

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

我正在开发一个平衡的三进制时钟,我想根据卡片调整面的大小。

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

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

【问题讨论】:

    标签: android wear-os android-cards watchface


    【解决方案1】:

    你问的是peek cards吗?如果是这样,则在该链接中记录了获取其尺寸。

    【讨论】:

    • 谢谢,我问的是偷看卡。我是 java 和 android 的新手,所以开发人员的演练对我帮助不大。我希望他们提供更多的代码示例,或者希望我能更好地找到他们提供的代码示例。
    • 我确实在github.com/googlesamples/android-WatchFace/blob/master/Wearable/…找到了一个对我有用的示例代码
    猜你喜欢
    • 1970-01-01
    • 2018-07-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-13
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    相关资源
    最近更新 更多