Migration Guide: strokeWidth and cornerRadius Density Scaling (v56.0)
This guide helps you migrate to the new density-independent pixel (dp) scaling behavior for strokeWidth and cornerRadius properties introduced in version 56.0.0.
Do You Need to Migrate?
Check your JSON configurations for strokeWidth and cornerRadius in cutoutConfig and scanFeedbackConfig:
-
If you’re not specifying these properties (using defaults) → Read carefully below (default changed from 2 to 0)
-
If you’re using custom values on high-density devices (xxhdpi, xxxhdpi) → Read carefully below (density scaling changed)
-
If you’re using low values (1-2) → Test your app to verify visual appearance
|
Two changes affect strokeWidth and cornerRadius:
|
Understanding the Change
|
The Previous behavior (Android only): These properties used raw pixel values without density scaling. A value of New behavior (Android and iOS): These properties are now density-independent pixels (dp) that automatically scale. A value of |
Example on xxhdpi device (3× density):
{
"strokeWidth": 2,
"cornerRadius": 4
}
-
Before (v55.x): 2 physical pixels and 4 physical pixels (no density scaling)
-
After (v56.0): 6 physical pixels and 12 physical pixels (2dp × 3 = 6px, 4dp × 3 = 12px)
Impact Across Device Densities
The behavior change primarily affects high-density displays:
| Device Density | DP Value | Before (px) | After (px) |
|---|---|---|---|
mdpi (1×) |
2 |
2 |
2 |
hdpi (1.5×) |
2 |
2 |
3 |
xhdpi (2×) |
2 |
2 |
4 |
xxhdpi (3×) |
2 |
2 |
6 |
xxxhdpi (4×) |
2 |
2 |
8 |
Key takeaway: On high-density displays (xxhdpi, xxxhdpi), cutout borders and feedback strokes will appear thicker than before.
Migration Options
Option 1: Accept Consistent Behavior (Recommended)
The new density scaling ensures consistent visual appearance across all device types and matches iOS rendering. Simply test your app on representative devices to verify the appearance meets your requirements.
Benefits:
-
Consistent visual thickness across all device densities
-
Matches iOS rendering for cross-platform consistency
-
Better user experience - UI elements maintain intended physical size
-
Aligns with Android design guidelines for dp usage
Option 2: Adjust Values for Previous Appearance
If you prefer the previous visual thickness on high-density displays, reduce your values proportionally:
// Old configuration (v55.x and earlier) on xxhdpi device
{
"strokeWidth": 6, // Rendered as 6px
"cornerRadius": 12 // Rendered as 12px
}
// New configuration for same visual appearance (v56.0+) on xxhdpi device
{
"strokeWidth": 2, // 2dp × 3 = 6px
"cornerRadius": 4 // 4dp × 3 = 12px
}
Common Scenarios
-
You increased values to compensate for thin lines on high-density devices: Reduce to original intended values (e.g., 6 → 2, 9 → 3)
-
You used low values (1-2) and they looked fine: Test on high-density devices; lines will be thicker but may look better
-
You relied on the default
cutoutConfig.strokeWidthof 2: The new default is0(no border) — explicitly set"strokeWidth": 2to restore the border appearance
Testing Recommendations
-
Test your app on devices with different densities (mdpi, hdpi, xxhdpi, xxxhdpi)
-
Verify cutout borders and scan feedback strokes appear at acceptable thickness
-
Check visual consistency across your target device range
-
Adjust values if needed - remember values are now in dp, not raw pixels
-
If you have both Android and iOS apps, compare visual appearance across platforms
Technical Details
Density conversion formula:
physical_pixels = dp_value × device_density
Examples:
- mdpi (1×): 2dp = 2px
- hdpi (1.5×): 2dp = 3px
- xhdpi (2×): 2dp = 4px
- xxhdpi (3×): 2dp = 6px
- xxxhdpi (4×): 2dp = 8px
Affected properties:
-
cutoutConfig.strokeWidth- Border width around the cutout -
cutoutConfig.cornerRadius- Corner rounding for cutout borders -
scanFeedbackConfig.strokeWidth- Line width for scan feedback visualization -
scanFeedbackConfig.cornerRadius- Corner rounding for feedback visualization
|
Get help
If there is anything you are missing, you require support, or want to provide us with feedback, please reach out to us via https://support.anyline.com, where you either may find helpful information in our Knowledge Base or you can open a Support Ticket for more specific inquiries. In order to better assist you, please include any code of your Anyline integration and any ScanViewConfig you are using. |