Creating code screenshots on Android is a task faced by both novice developers and experienced programmers. Unlike ordinary screenshots, it is important here to save Text readability, transmit correctly Syntax highlighting and avoid compression artifacts. The problem is complicated by the fact that standard Android tools do not always cope optimally with fixing small text in the IDE or terminal.
In this article we will look 5 proven methods - from built-in tools to professional solutions with using ADB and third-party utilities. You will learn how to take a screenshot of code on Samsung DeX, in Termux or through Android Studio, and also receive recommendations for post-processing images for documentation. Particular attention is paid to the nuances of working with dark themes and high screen resolution.
1. Standard keyboard shortcuts: when it's enough
Most Android devices support basic shortcuts for screenshots, but their effectiveness depends on code font size and screen resolution. The classic methodโpress and hold Power + Volume Down โworks on 90% of devices, but has limitations:
- ๐ฑ On Samsung Galaxy (One UI) add your finger to the screen to select an area (function
Scroll Captureavailable in the toolbar after taking a photo). - ๐ฅ๏ธ On tablets with Android 12+ hold
Power1 second longer - a menu will appear with optionScreenshot. - โ๏ธ On Xiaomi (MIUI) three fingers down the screen activate the snapshot (configurable in
Settings โ Advanced โ Gestures).
For code, these methods are suitable if:
- ๐ The font is no less than
14px(otherwise the text will be unreadable). - ๐ You need to capture no more than one screen (without scrolling).
- ๐จ The background is contrasting (a dark theme on AMOLED screens gives the best result).
โ ๏ธ Attention: On devices with dynamic resolution (for example, Pixel 6 Pro) screenshots may be saved in reduced quality Before shooting, fix the resolution. in Settings โ Display โ Screen resolution.
2. Screenshots via ADB: for developers and root users
The tool Android Debug Bridge (ADB) allows you to take screenshots from maximum resolution, bypassing the limitations of standard methods. This is the only way to get a screenshot of the code in Termux or UserLAnd without loss of quality.
Instructions:
- Connect the device to the PC and activate
USB debugging(Settings โ About phone โ Build number- tap 7 times, then return inSettings โ System โ For developers). - In the PC terminal, do:
adb shell screencap -p /sdcard/screenshot.pngadb pull /sdcard/screenshot.png - For compression without losses, add a flag
-z(required Android 11+).
Advantages of the method:
- ๐ธ Saves original resolution screen (including
1440pon flagships). - โก Works on devices without physical buttons (for example, Google Pixel Fold).
- ๐ง Allows you to automate the process through scripts (for example, for a series of screenshots).
| ADB command | Description | Required rights |
|---|---|---|
screencap -p |
Snapshot of the entire screen in PNG | Without root |
screencap -p | sed 's/\r$//' > screenshot.png |
Fixing artifacts on Windows | Without root |
su -c screencap -p /data/local/tmp/screen.png |
Snapshot with root access (bypasses DRM restrictions) | Root |
โ ๏ธ Attention: On devices with Widevine L1 (for example Sony Xperia 1 IV) screenshots via ADB can be blocked by DRM protection. In this case, use the method with scrcpy (see section 4).
Install ADB on the PC (platform-tools)|Enable USB debugging|Connect the device via cable|Check the connection with the command `adb devices`-->
3. Specialized applications: Screen Master, Screenshot Touch and others
For users who need advanced functions (for example, capturing scrollable windows or editing), third-party utilities will do. We tested 10 applications and selected the top 3 for working with code:
- Screen Master (๐ Recommended):
- ๐ Support
Scroll Capturefor long code listings. - ๐จ Built-in editor with syntax highlighting (recognizes
Java,Kotlin,Python). - ๐ Option to increase the shooting area (useful for small text).
- ๐ Support
- Screenshot Touch:
- ๐ผ๏ธ Saving in
PNG/JPG/WEBwith settings quality. - ๐ Automatic loading to Google Drive or GitHub Gist.
- ๐ผ๏ธ Saving in
- ๐ Ideal for screenshots Termux with scrolling.
- ๐ง Setting the delay before shooting (to minimize the keyboard).
How to choose an application?
- For Android Studio or VS Code (via DeX) is suitable Screen Master - it handles dark themes correctly.
- For Termux or JuiceSSH better LongShot โit can capture terminal buffers.
- If needed auto-export to Markdown, test Screenshot Touch with the plugin
Code Snap.
โ ๏ธ Attention: Applications with the function Scroll Capture may not work correctly on devices with non-standard aspect ratio (for example, Samsung Galaxy Z Flip). Test the free version before purchasing.
How to bypass DRM restrictions when shooting code?
Some applications (for example, Netflix or Disney+) block screenshots using standard methods. If you need to capture the code in a secure environment (for example, Secure Folder on Samsung), use the workaround:
1. Enable Developer mode and disable HDCP content protection (on some devices).
2. Use scrcpy to stream the screen to a PC and take a photo there.
3. To Termux redirect the output to file: cat file.py > /sdcard/code.pythen open the file in a text editor and take a screenshot.
4. Screenshots via scrcpy: screen streaming on PC
The utility scrcpy allows mirroring the Android screen to a computer to take screenshots with a resolution of up to 4K. This is the optimal solution for:
- ๐ฅ๏ธ Fixing code in Android Studio or Termux with perfect readability.
- ๐ฎ Capturing interaction with emulators (Genymotion, BlueStacks).
- ๐ Shooting with zoom (useful for presentations).
Setup instructions:
- Download
scrcpys official repository (required ADB). - Connect your device and run:
scrcpy --bit-rate 8M --max-size 1920(for full screen mode with high bitrate).
- On PC use
PrtScnorShift+Win+S(Windows) to capture.
Advanced options:
- ๐ Change the stream resolution:
--max-size 2560for QHD devices. - ๐ Turn off the sound:
--no-audio(reduces the load). - ๐ผ๏ธ Save screenshots automatically:
--record file.mp4+ subsequent export of frames via FFmpeg.
If the code is displayed blurry, add flag --display 0 (for the main display) or --crop to crop unnecessary areas. For example: scrcpy --crop 1080:1920:0:0 captures only the left half of the screen.
5. Capturing code in Samsung DeX and other desktop modes allows you to use your Android device as a full-fledged PC. In these modes, standard screenshots are often taken through:
Samsung DeX, Huawei Desktop Mode And Motorola Ready For allow you to use your Android device as a full-fledged PC. In these modes, standard screenshots are often taken via:
- ๐ฑ๏ธ Combination
Alt + PrtScn(emulates a PC keyboard). DeX emulates a PC keyboard). - ๐ Built-in utility
DeX Screenshot Tool(available in the taskbar). - ๐ง Settings
Screen resolutionto1440pfor better quality.
Features of shooting code in desktop modes:
- ๐ Android Studio v DeX allows you to take screenshots via
File โ Save Screenshot(saves with syntax highlighting). - ๐ผ๏ธ Termux enlarge font up
20pxbefore shooting (in the terminal settings). - ๐ For VS Code use the extension
CodeSnapโit automatically formats the code before saving.
| Mode | Max. screenshot resolution | Scroll Capture support |
|---|---|---|
| Samsung DeX | 3840ร2160 (4K) |
Yes (via Shift+PrtScn) |
| Huawei Desktop Mode | 2560ร1440 (QHD) |
No |
| Motorola Ready For | 1920ร1080 (FHD) |
Yes (with update 2023) |
DeX and similar modes provide the highest quality code screenshots thanks to the ability to use โdesktopโ shooting and zooming tools.
6. Post-processing of screenshots: how to make them professional
Even the perfect screenshot often requires modification before publication. It is critical for the code:
- ๐ Readability: increase the contrast or invert the colors if the background. merges with the text.
- ๐ Cropping: remove unnecessary interface elements (toolbars, keyboard).
- ๐จ Backlight syntax: if it is not in the screenshot, add it manually to Photoshop or GIMP.
Recommended tools:
- ๐๏ธ Snagit: automatic code highlighting, adding arrows and annotations.
- ๐ฑ Lightshot (Android): quick editing directly on the device.
- ๐ป Carbon.now.sh: generation of "beautiful" code snapshots with background (upload a screenshot and process it online).
An example of a command for cropping through FFmpeg:
ffmpeg -i screenshot.png -vf "crop=1000:800:50:100" output.png
(where 1000:800 is the width and height of the cropped area, 50:100 is the offset from the upper left corner).
โ ๏ธ Attention: When publishing screenshots in GitHub README or documentation, optimize them throughtinypng.com. Images weighing more than500 KBcan slow down page loading.
7. Alternative methods: when a screenshot is not suitable
Sometimes a screenshot is not the best solution. Consider the alternatives:
- ๐ Copy text: in Termux or Android Studio highlight the code and export in
.txt/.py. - ๐น Write screen: to demonstrate the process, use
adb shell screenrecord. - ๐ Export project: in Android Studio click
File โ Export to ZIP.
When to abandon the screenshot:
- ๐ Code longer than 50 lines (itโs better to attach file).
- ๐ Need to show dynamic execution (use
GIFvia ScreenToGif). - ๐ Code contains confidential data (API keys, passwords).
termux-screenshot -c "sleep 3; input tap 100 200" output.gif
(where sleep 3 โdelay before shooting, input tap โsimulation of pressing to scroll).-->
FAQ: Frequently asked questions about screenshots of code on Android
Is it possible to take a screenshot of code in Termux without root?
Yes, use the combination Volume Down + Power or command termux-screenshot -f /sdcard/termux_screenshot.png. For scrollable windows, install LongShot from F-Droid.
Why are screenshots blurry in Android Studio?
The problem is related to interface scaling. Before shooting:
- Disable
Override font scalingin the IDE settings. - Install the font
16pxor more. - Use DeX or
scrcpyfor shooting from a PC.
How to take a screenshot of code on a tablet with a keyboard (for example, Samsung Tab S8+)? summary>
On tablets with a connected keyboard, hotkeys work:
Win + PrtScn โ saves to Pictures/Screenshots.
Alt + PrtScn โ copies to the clipboard (paste to Paint or GIMP).
If the keys do not work, check the settings in System โ Keyboard โ Keyboard shortcuts.
Win + PrtScn โ saves to Pictures/Screenshots.Alt + PrtScn โ copies to the clipboard (paste to Paint or GIMP).System โ Keyboard โ Keyboard shortcuts.Is it possible to automate the creation of screenshots of code for documentation?
Yes, using scripts. Example for Termux:
#!/bin/bashTakes a screenshot, crops and converts to JPG
termux-screenshot -f /sdcard/code.png
convert /sdcard/code.png -crop 80% +repage /sdcard/code_cropped.jpg
For Android Studio use plugin Screenshot Generatorthat automatically creates snapshots with syntax highlighting.
How to take a screenshot of code on Android Go or devices with 1 GB of RAM?
On low-power devices:
- Disable animations in
Settings โ For developers โ Animation scale (off). - Use lightweight applications: Screenshot Easy (weight 2 MB) or
ADB. - Reduce the screen resolution before shooting (in
Settings โ Display).
Avoid Scroll Capture - this may cause the device to reboot.