Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 519
Josh Hansen Avatar asked Jan 28 '23 12:01

Josh Hansen


2 Answers

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

custom devices

like image 144
Chisko Avatar answered Jan 31 '23 20:01

Chisko


Follow these steps:

1) Click on "Add Device Definition..."

2) Make your specific device in opened window

3) restart Android Studio

4) you can find Your New device in the list. (above of "Generate Phones and Tablets" in AVD Devices part)

like image 44
mhKarami Avatar answered Jan 31 '23 18:01

mhKarami