.opencode/skills/android-dimens/SKILL.md
Guide using dimension resources for UI sizes, spacings, and paddings in Android Compose. Use when creating or modifying UI components, replacing hardcoded dp values, or ensuring consistency across Compose screens.
npx skillsauth add easydev991/Jetpack-WorkoutApp android-dimensInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
*.dp values with dimension resourcesimport androidx.compose.ui.res.dimensionResource
import com.swparks.R
All paddings, sizes, spacings, and dimensions must come from app/src/main/res/values/dimens.xml.
Bad:
Modifier.padding(16.dp)
Modifier.size(32.dp)
Arrangement.spacedBy(8.dp)
Good:
Modifier.padding(horizontal = dimensionResource(id = R.dimen.spacing_regular))
Modifier.size(dimensionResource(id = R.dimen.icon_size_small))
Arrangement.spacedBy(dimensionResource(id = R.dimen.spacing_xsmall))
Use existing spacing tokens from dimens.xml:
// Examples of existing spacings:
dimensionResource(id = R.dimen.spacing_xxsmall) // 4dp
dimensionResource(id = R.dimen.spacing_regular) // 16dp - standard spacing (most common)
dimensionResource(id = R.dimen.spacing_large) // 24dp - large spacing
Use existing icon size tokens from dimens.xml:
// Examples of existing icon sizes:
dimensionResource(id = R.dimen.icon_size_small) // 32dp
dimensionResource(id = R.dimen.icon_size_medium) // 42dp
dimensionResource(id = R.dimen.icon_size_large) // 48dp
Use existing common size tokens from dimens.xml:
// Examples of existing common sizes:
dimensionResource(id = R.dimen.size_small) // 32dp
dimensionResource(id = R.dimen.size_medium) // 48dp
dimensionResource(id = R.dimen.size_large) // 80dp
Use existing border and elevation tokens from dimens.xml:
// Examples of existing values:
dimensionResource(id = R.dimen.border_width_small) // 2dp
dimensionResource(id = R.dimen.elevation_none) // 0dp
dimensionResource(id = R.dimen.elevation_small) // 2dp
dimensionResource(id = R.dimen.elevation_medium) // 4dp
Use existing corner radius tokens from dimens.xml:
// Examples of existing corner radii:
dimensionResource(id = R.dimen.corner_radius_none) // 0dp
dimensionResource(id = R.dimen.corner_radius_small) // 8dp
dimensionResource(id = R.dimen.corner_radius_bubble) // 20dp
Use existing component-specific tokens from dimens.xml:
// Examples of existing component-specific values:
dimensionResource(id = R.dimen.bubble_horizontal_margin) // 40dp
dimensionResource(id = R.dimen.bubble_padding_horizontal) // 18dp
Only add new dimensions when:
Naming and sorting rules:
Example: if dimens.xml already has spacing_regular = 16dp and spacing_large = 24dp, and you need to add 20dp:
spacing_medium = 20dp (if available)spacing_medium = 20dp and place it by numeric value between regular and largespacing_regularplus — illogical, as 20 is exactly halfway between 16 and 24Examples of logical naming:
<!-- Check existing values in dimens.xml -->
<dimen name="spacing_regular">16dp</dimen>
<!-- If you need 20dp - check if spacing_medium exists -->
<dimen name="spacing_medium">20dp</dimen> ← use or create by numeric value
<dimen name="spacing_large">24dp</dimen>
Naming conventions:
spacing_<semantic> (e.g., spacing_regular, spacing_medium, spacing_micro)icon_size_<semantic> or icon_<semantic> (e.g., icon_size_small, icon_size_avatar)corner_radius_<semantic> (e.g., corner_radius_small, corner_radius_bubble)<component>_<property> (e.g., bubble_horizontal_margin)Modifier.padding(...) with hardcoded valuesModifier.size(...) with hardcoded valuesArrangement.spacedBy(...) with hardcoded valuesRoundedCornerShape(...) with hardcoded values*.dp value in Compose UI code (except Preview functions)When replacing hardcoded values:
androidx.compose.ui.res.dimensionResourcecom.swparks.R (if not already present)dimens.xml firstdimensionResource(id = R.dimen.<name>)make format after changes./gradlew buildColumn(
modifier = Modifier
.fillMaxWidth()
.padding(dimensionResource(id = R.dimen.spacing_regular))
) {
// Content with padding on all sides
}
Column(
modifier = Modifier
.fillMaxWidth()
.padding(
horizontal = dimensionResource(id = R.dimen.spacing_regular),
vertical = dimensionResource(id = R.dimen.spacing_small)
)
) {
// Content with horizontal and vertical padding
}
Column(
verticalArrangement = Arrangement.spacedBy(dimensionResource(id = R.dimen.spacing_small))
) {
// Items with spacing between them
}
Icon(
imageVector = Icons.Default.Person,
contentDescription = null,
modifier = Modifier.size(dimensionResource(id = R.dimen.icon_size_medium))
)
Card(
shape = RoundedCornerShape(dimensionResource(id = R.dimen.corner_radius_small))
) {
// Card content
}
testing
Пиши тесты в андроид-проекте правильно. Используй этот навык при написании любых типов тестов (unit, integration, UI), тестировании бизнес-логики, сетевых функций и компонентов UI.
tools
Реализуй pull-to-refresh в Jetpack Compose с использованием Material 3 PullToRefreshBox. Используй этот навык при добавлении возможности обновления данных на экранах со списками или карточками.
tools
Правильно работай с локализацией в Android-проекте. Используй этот навык при добавлении новых строковых ресурсов, работе с plurals, форматировании дат и текстов.
tools
Блокировка UI контента экрана во время загрузки данных или выполнения асинхронных операций с отображением индикатора загрузки. Используй этот навык при разработке экранов с сетевыми запросами, операциями CRUD и других асинхронных действий.