I created some custom elements, and I want to programmatically place them to the upper right corner ( n
pixels from the top edge and m
pixels from the right edge). 我建立了一些自定义元素,我想以编程方式将它们放置在右上角(顶部边缘n
像素,右侧边缘m
像素)。 Therefore I need to get the screen width and screen height and then set position: 所以,我须要获取屏幕宽度和屏幕高度,而后设置位置: 编程
int px = screenWidth - m; int py = screenHeight - n;
How do I get screenWidth
and screenHeight
in the main Activity? 如何在主活动中获取screenWidth
和screenHeight
? spa