@notrezponding/cap-rounded-corners
v1.0.4
Published
Capacitor plugin to detect Android device's rounded corner radius
Downloads
43
Maintainers
Readme
Capacitor Rounded Corner Plugin
A Capacitor plugin to detect the rounded corner radius of Android devices.
Installation
npm install @notrezponding/cap-rounded-corners
npx cap syncUsage
import RoundedCorners from "@notrezponding/cap-rounded-corners";
const getCornerRadius = async () => {
const result = await RoundedCorners.getCornerRadius();
if (result.success) {
console.log("Corner radius (DP):", result.cornerRadius);
console.log("Corner radius (Pixels):", result.cornerRadiusPx);
} else {
console.error("Error:", result.error);
}
};API
getCornerRadius()
Returns the device's rounded corner radius in both DP (density-independent pixels) and raw pixels.
Returns:
cornerRadius: number - The corner radius in DP (density-independent pixels)cornerRadiusPx: number - The corner radius in raw pixelssuccess: boolean - Whether the operation was successfulerror: string (optional) - Error message if the operation failed
Note:
- On Android versions below Q (API 29), this will return 0 as the corner radius and success will be false
- The
cornerRadiusvalue (in DP) is what you typically want to use in your UI, as it accounts for the device's screen density - The
cornerRadiusPxvalue is the raw pixel value, which may appear larger on high-DPI screens
