我在monkeyrunner脚本下面运行但看起来display.height与快照图像高度不一样。
在我的情况下,显示.height为2360,但快照图像高度为2560。
#!/usr/bin/env monkeyrunner
import time
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
#----------------------------------------#
def main():
device = MonkeyRunner.waitForConnection()
device.wake()
time.sleep(1)
screenW = float(device.getProperty("display.width"))
screenH = float(device.getProperty("display.height"))
screenD = device.getProperty("display.density")
print "screen size: %dx%d density:%s"%(screenW,screenH,screenD)
return
#----------------------------------------#
def touch(device,x,y,action=MonkeyDevice.DOWN_AND_UP):
screenW = float(device.getProperty("display.width"))
screenH = float(device.getProperty("display.height"))
screenD = device.getProperty("display.density")
print int(screenW*x),int(screenH*y)
device.touch(int(screenW*x),int(screenH*y),action)
return
#----------------------------------------#
def startActivity(device,package,activity):
component_name = package + "/" + activity
device.startActivity(component=component_name)
return
#----------------------------------------#
def snapshot(device,filename):
result = device.takeSnapshot()
result.writeToFile(filename,'png')
return
#----------------------------------------#
if __name__ == '__main__':
main()
#----------------------------------------#
如何获得2560(就像快照高度一样)作为属性?我想也许display.height不是指屏幕高度?