任何显示之前获取窥视卡的高度? [英] Get height of peek card before any are displayed?

查看:289
本文介绍了任何显示之前获取窥视卡的高度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据API文档,所有的窥视卡将只能是单行高时PEEK_MODE_SHORT设置。因此,这意味着每一个窥视卡将占据屏幕房地产恒定为特定设备。

According the the API docs, all peek cards will only be "a single line tall" when PEEK_MODE_SHORT is set. So this means every peek card will occupy a constant of screen real estate for a particular device.

我打算放置在有保证不被卡(和空非临界指数的信息可能被卡支付)所覆盖区域最重要的信息,以利用这个对我的手表的脸。

I plan to leverage this on my watch face by placing the most important info in the area that's guaranteed not to be covered by a card (and the non-critial info in the space which could be covered by a card).

问题是我不知道如何确定偷看牌多大的存储空间,直到<一个href=\"https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#onPeekCardPositionUpdate(android.graphics.Rect)\"相对=nofollow> onPeekCardPositionUpdate(),这是为时已晚,因为我想布局的其余部分考虑到那里偷看牌会去。

The problem is I don't know how to determine how much space the peek cards take until onPeekCardPositionUpdate(), which is too late, because I want the rest of the layout to take into consideration where the peek cards will go.

TL; DR - 如何让onPeekCardPosition前偷看牌位置的任何想法()被调用

TL;DR - Any ideas on how to get the peek card positions before onPeekCardPosition() is called?

编辑:
我需要偷看牌高度的原因是因为我期待,以确保事情会的完全的显示卡偷看时覆盖。像下面#1:

The reason I need the peek card height is because I'm looking to ensure that something will be fully covered when the peek card is displayed. Like #1 below:

推荐答案

没有,我们没有提供任何API,以确定偷看牌的高度。您应该使用 onPeekCardPositionUpdate()键,让你的表盘调整,当它接收到通知。

No, we didn't provide any API to determine the height of the peek card. You should use onPeekCardPositionUpdate() and make your watch face adjust, when it receives the notification.

据我了解,你想始终把偷看牌上面的内容,并用它做。然而,这不是一个好主意 -​​ 你将浪费地产提供给你在屏幕上。用户可能决定禁用窥测(有可用于该选项)之后就将留下空的空间在屏幕的底部。或者用户可能没有流卡,在其中再次情况下,你将留下底部空。

I understand that you would like to always put your content above the peek card and be done with it. However, this is not a good idea - you will be wasting real estate available to you on the screen. The user might decide to disable the peeking (there are options available for this) after which you will be left with empty space at the bottom of the screen. Or the user might not have cards in the stream, in which case again, you will be left with empty space at the bottom.

此回调提供了一个理由,这样你就可以动态地调整你的手表表面既当卡被偷看,当它不是,并允许用户在这两种情况下最好的体验。

This callback is provided for a reason, so you can dynamically adjust your watch face both when a card is peeking and when it's not and allow users to have best experience in either case.

编辑:

在您的具体情况,我建议这样做:在您的绘图code检查偷看卡的当前范围(<一个href=\"https://developer.android.com/reference/android/support/wearable/watchface/WatchFaceService.Engine.html#getPeekCardPosition()\"相对=nofollow> getPeekCardPosition() )。如果它们是(0-0,0-0),这意味着没有偷看牌,你能画可选一块内容。如果边界是不同的,不画了。它应该是这么简单。你也想​​触发重绘当即将卡界限回调来了。

In your specific case, I would recommend doing this: in your drawing code check the current bounds of the peek card (getPeekCardPosition()). If they are (0-0, 0-0), this means there is no peek card and you can draw the optional piece of content. If the bounds are different, don't draw it. It should be as easy as that. You also want to trigger redraw when the callback about the card bounds comes.

这篇关于任何显示之前获取窥视卡的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆