UWP 判断windows mobile是使用的实体键还是虚拟按键

最近在写启动屏幕,发现虚拟按钮会挡住,启动屏幕的最下面的元素,大概有50 px。可是有什么办法知道手机是用的实体键还是虚拟按键吗?

如下图。可以看到红色的部分显示了一点点。代码里设置的是60px。

在网上查找了很久。都没发现有任何查看的api。瞬间在心里开始骂ms了。。

各种论坛各种询问。

最后有一个机油回答到

试了一试。。嗯。。虚拟按键全屏的时候会消失掉。。可是。。这不我想要的啊。。

突然间灵光一闪。。想起有这样一种东西。ApplicationView.GetForCurrentView().VisibleBounds 

于是debug一看。。嘿嘿嘿。终于找到想要的东西。。

 double statusbarHeight = 0;
 if(ApiInformation.IsTypePresent("Windows.UI.ViewManagement.StatusBar"))
        statusbarHeight= StatusBar.GetForCurrentView().OccludedRect.Height;


//Gets the visible region of the window (app view). The visible region is the region 
//not occluded by chrome such as the status bar and app bar.   
var visibleBounds = ApplicationView.GetForCurrentView().VisibleBounds;

var virtualButtonHeight = extendedSplashImage.Height - visibleBounds.Height - statusbarHeight;

最后这个虚拟按键的高度 = SplashScreen的高度 - VisibleBounds.Height- statusbarHeight。

1520实体按键和950XL虚拟键测试通过。。

最后再吐槽下ms。。什么时候出surface phone啊。信仰都用完了。。

 

posted @ 2016-11-15 11:25  法的空间  阅读(949)  评论(2编辑  收藏  举报