Hansvdg
Hansvdg

Reputation: 121

How to change orientation in Android Device Monitor "Dump View Hierarchy"

In Android Device Monitor there is a tool to dump the view hierarchy for UI automator.

I want to debug the UI for a landscape tablet app, but the screenshot is captured in portrait mode, how can I change this to landscape. The "Screen Capture" option in Android Device Monitor does take a screenshot in landscape mode.

Android Device Monitor: 24.4.1

Device: HTC Nexus 9 running Android 6.0

Upvotes: 5

Views: 1821

Answers (2)

Ashish
Ashish

Reputation: 195

Apart from the solution(which is not working for Mac Users), you the try this:

  1. Take the screen in UIAutomatorViewer
  2. Click on Save and save in some location(this will save both .png and .uix file)
  3. Go to the saved location and rotate .png file accordingly
  4. In UIAutomatorViewer, open that .png file and ta da, you got your app view

Upvotes: 0

Stan
Stan

Reputation: 8768

I also have encountered the problem: the screenshot of a device in landscape orientation is displayed vertical in the View Hierarchy window. It's important, that control boundaries are highlighted correctly as if the screenshot has horizontal orientation, but since the image is not rotated accordingly, the highlighting is inconsistent with the image. The only workaround I have found is to rotate the image manually.

DDMS stores view hierarchy dump in a temporary folder. In my case it is located in the following Windows path: C:\Documents and Settings\User\Local Settings\Temp\uiautomatorviewer_[number]. You may see the full path in a floating tooltip appearing when you hover your mouse on the .uix file tab.

After you noted the path, close the .uix tab for a moment.

The folder on the path contains the .uix file itself and an image (.png). The quick fix is to rotate the image by an applicable program. I did it in Windows with standard tools:

  • right click on the image;
  • choose Preview command;
  • in the Preview window use Rotate Clockwise (Ctrl+K);

Now open the .uix file anew in the IDE. It will most likely ask you to Specify screenshot - press this button and choose the modified .png file. Voila.

Upvotes: 8

Related Questions