Skip to content

Commit 2f119c8

Browse files
committed
feat: add screen resolution and density customization
1 parent 92e2c8f commit 2f119c8

4 files changed

Lines changed: 44 additions & 5 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ Thumbs.db
1111
.idea/
1212

1313
# Docker compose data
14-
data/
14+
data*/

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ Access and control the Android emulator directly in your web browser with the in
3535
- [Using Web Interface](#use-the-web-interface-to-access-the-emulator)
3636
- [Using ADB](#connect-via-adb)
3737
- [Using Desktop scrcpy](#use-scrcpy-to-mirror-the-emulator-screen)
38+
- [Customizing Device Screen](#customizing-device-screen)
3839
- [First Boot Process](#-first-boot-process)
3940
- [Container Logs](#-container-logs)
4041
- [Roadmap](#-roadmap)
@@ -134,6 +135,31 @@ scrcpy -s localhost:5555
134135

135136
> **Note:** Ensure `scrcpy` is installed on your host machine. [Installation Guide](https://github.com/Genymobile/scrcpy#installation)
136137
138+
### Customizing Device Screen
139+
140+
The emulator's display can be adjusted with environment variables:
141+
142+
- `SCREEN_RESOLUTION` (optional): sets the screen size in `WIDTHxHEIGHT` format.
143+
- `SCREEN_DENSITY` (optional): overrides the device pixel density in DPI.
144+
145+
#### Docker run example
146+
147+
```bash
148+
docker run -e SCREEN_RESOLUTION=1440x2560 -e SCREEN_DENSITY=560 shmayro/dockerify-android:latest
149+
```
150+
151+
#### docker-compose snippet
152+
153+
```yaml
154+
environment:
155+
# Optional screen resolution in WIDTHxHEIGHT format
156+
# - SCREEN_RESOLUTION=1440x2560
157+
# Optional screen density (dpi)
158+
# - SCREEN_DENSITY=560
159+
```
160+
161+
If `SCREEN_RESOLUTION` or `SCREEN_DENSITY` are omitted, the emulator uses its default settings.
162+
137163
## 🔄 **First Boot Process**
138164

139165
The first time you start the container, it will perform a comprehensive setup process that includes:

docker-compose.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
services:
23
dockerify-android:
34
container_name: dockerify-android
@@ -7,15 +8,19 @@ services:
78
ports:
89
- "5555:5555"
910
volumes:
10-
- ./data:/data
11+
- ./data-tmp:/data
1112
- ./extras:/extras
1213
environment:
1314
- DNS=one.one.one.one
1415
- RAM_SIZE=8192
16+
# Optional screen resolution in WIDTHxHEIGHT format
17+
#- SCREEN_RESOLUTION=720x720
18+
# Optional screen density (dpi)
19+
#- SCREEN_DENSITY=227
1520
privileged: true
1621
devices:
1722
- /dev/kvm
18-
23+
1924
scrcpy-web:
2025
container_name: scrcpy-web
2126
restart: unless-stopped
@@ -30,4 +35,4 @@ services:
3035
sh -c "
3136
adb connect dockerify-android:5555 &&
3237
npm start
33-
"
38+
"

start-emulator.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,13 @@ if [ -f /data/.first-boot-done ]; then
55
RAMDISK="-ramdisk /data/android.avd/ramdisk.img"
66
fi
77

8+
# Configure optional screen resolution and density
9+
if [ -n "$SCREEN_RESOLUTION" ]; then
10+
SCREEN_RESOLUTION_FLAG="-skin $SCREEN_RESOLUTION"
11+
fi
12+
if [ -n "$SCREEN_DENSITY" ]; then
13+
SCREEN_DENSITY_FLAG="-dpi-device $SCREEN_DENSITY"
14+
fi
15+
816
# Start the emulator with the appropriate ramdisk.img
9-
/opt/android-sdk/emulator/emulator -avd android -nojni -netfast -writable-system -no-window -no-audio -no-boot-anim -skip-adb-auth -gpu swiftshader_indirect -no-snapshot -no-metrics $RAMDISK -qemu -m ${RAM_SIZE:-4096}
17+
/opt/android-sdk/emulator/emulator -avd android -nojni -netfast -writable-system -no-window -no-audio -no-boot-anim -skip-adb-auth -gpu swiftshader_indirect -no-snapshot -no-metrics $SCREEN_RESOLUTION_FLAG $SCREEN_DENSITY_FLAG $RAMDISK -qemu -m "${RAM_SIZE:-4096}"

0 commit comments

Comments
 (0)