How to use a custom resolution in Android Studio's layout editor?

Josh Hansen picture Josh Hansen · Mar 12, 2018 · Viewed 8.4k times · Source

Sometimes I'm editing the layout resource for a list item or similar small UI component. This is nice, but the available screen resolutions in the layout editor in Android Studio are all way too big to get a reasonable sense of how the list item or whatever will look. Even when using the smallest resolution available (2.7" QVGQ) there's always a ton of unused space:

enter image description here

If I try to have elements match_parent or match_constraint then they blow up to take up the entire space of the editor:

enter image description here

How can I use custom screen resolutions in Android Studio's layout editor? It would let me get a better idea of how these smaller UI component layouts will actually look. My Google searches have all been futile. Within Android Studio I was able to add a new device definition with a very small resolution, but it doesn't show up in the list of available resolutions in the layout editor. Help!

UPDATE:

I checked in the "Generic Phones and Tablets" menu as per Chisko's suggestion below, but my virtual device wasn't there.

enter image description here

enter image description here

BUT after restarting Android studio, it appeared:

enter image description here

So Chisko is right, but there also appears to be a bug in Android Studio where the creation of a virtual device isn't reflected in the "Generic Phones and Tablets" menu until a restart has occurred.

Answer

Chisko picture Chisko · Mar 12, 2018

If you added a custom device try looking on Generic Phones and Tablets option. Refer to screenshot:

custom devices