Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

android

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

like image 696
Hansvdg Avatar asked Nov 02 '15 12:11

Hansvdg


1 Answers

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.

like image 86
Stan Avatar answered Nov 15 '22 00:11

Stan