Bodenberg.AppDimens.Sdps 3.6.0

dotnet add package Bodenberg.AppDimens.Sdps --version 3.6.0
                    
NuGet\Install-Package Bodenberg.AppDimens.Sdps -Version 3.6.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bodenberg.AppDimens.Sdps" Version="3.6.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bodenberg.AppDimens.Sdps" Version="3.6.0" />
                    
Directory.Packages.props
<PackageReference Include="Bodenberg.AppDimens.Sdps" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bodenberg.AppDimens.Sdps --version 3.6.0
                    
#r "nuget: Bodenberg.AppDimens.Sdps, 3.6.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bodenberg.AppDimens.Sdps@3.6.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bodenberg.AppDimens.Sdps&version=3.6.0
                    
Install as a Cake Addin
#tool nuget:?package=Bodenberg.AppDimens.Sdps&version=3.6.0
                    
Install as a Cake Tool

Bodenberg.AppDimens.Sdps

.NET 10 binding for Android (net10.0-android) that wraps AppDimens SDPS — responsive layout (SDP / HDP / WDP) and typography (SSP / HSP / WSP) in one library, backed by thousands of pre-generated @dimen resources, plus imperative APIs, conditional facilitators, aspect-ratio variants, accessibility text modes, and foldable-aware overloads.

Kotlin/Java sources, XML naming, and Android-focused guides live upstream:

bodenberg/appdimens-sdps

Maven artifact embedded in this package: io.github.bodenberg:appdimens-sdps 3.1.7.


Install

dotnet add package Bodenberg.AppDimens.Sdps --version 3.6.0

Pin a version explicitly when you rely on a specific package revision (see Package version vs embedded AAR below).


Requirements

Requirement Notes
Target framework net10.0-android (.NET for Android / .NET MAUI Android)
Minimum Android API 24 (matches the packaged AAR)
Workload Android (dotnet workload install android) or MAUI
JDK 17 or 21 for the Xamarin.Android toolchain on .NET 10

Use Android SDK platform 36+ (or MSBuild InstallAndroidDependencies) when building bindings locally on .NET 10.

The AAR bundles values-sw* / values-w* / values-h* dimen XML (sizes 1–600) for both dp and sp buckets.


What this library provides

Capability Summary
SDP / HDP / WDP Scale margins, padding, sizes by smallest width, height, or width
SSP / HSP / WSP Scale text on the same three axes
SEM / HEM / WEM Typography curves that ignore system font scale
XML @dimen e.g. @dimen/_16sdp, @dimen/_32hsp — zero-config in layouts
Code API DimenSdp / DimenSsp → pixel values for Views, custom drawing, MAUI
Aspect ratio Sdpa, Sspa, … — geometry multiplier on top of the XML bucket
Multi-window Sdpi, Sspia, … — parity with Dynamic “ignore scaling” paths
Inverters SdpPh, HspLw, WdpLh, … — orientation-aware axis switch
Facilitators Rotate, Mode, Qualifier, Screen (+ Plain px variants for dp)
Builders DimenScaled (layout) and ScaledSp (text) — priority-based rule lists
Physical units DimenPhysicalUnits — mm / cm / inch helpers
Prefetch WarmupSdpsFactors — optional aspect-ratio factor warmup

SDPS is the all-in-one responsive dimen package (layout + type). Use AppDimens SSPS if you only need typography, or AppDimens Dynamic for code-only multi-strategy scaling without XML grids.


C# namespaces (binding layout)

Public Kotlin @JvmStatic APIs appear under Com.Appdimens.Sdps.*:

Area Namespace / types
Views / imperative (recommended) Com.Appdimens.Sdps.Code
Layout (dp) DimenSdp, DimenScaled, CustomDpEntry
Typography (sp) DimenSsp, ScaledSp, CustomSpEntry
Physical units DimenPhysicalUnits
Extensions DimenExtensionsKt, DimenSspExtensionsKt, DimenSspScaledKt
Shared enums Com.Appdimens.Sdps.CommonDpQualifier, Inverter, Orientation, UiModeType, UnitType
AR factors Com.Appdimens.Sdps.CoreAppDimensSdpsFactors
Compose (limited) Com.Appdimens.Sdps.Compose.* — see Jetpack Compose below

Foldable overloads accept AndroidX.Window.Layout.IFoldingFeature from Xamarin.AndroidX.Window.


Quick start (Activity / Views)

using Android.App;
using Android.OS;
using Com.Appdimens.Sdps.Code;

[Activity(Label = "My App", MainLauncher = true)]
public class MainActivity : Activity
{
    protected override void OnCreate(Bundle? savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        DimenSdp.WarmupSdpsFactors(this);

        float paddingPx = DimenSdp.Sdp(this, 16);
        float cardHeight  = DimenSdp.Hdp(this, 120);
        float bannerWidth = DimenSdp.Wdp(this, 200);

        float titlePx = DimenSsp.Ssp(this, 20);
        float bodyPx  = DimenSsp.Ssp(this, 14);
    }
}

Apply paddingPx / titlePx as pixel sizes on View layout params or TextView.TextSize.


Layout dimensions (DimenSdp)

All methods return pixels (float) for a nominal dp integer (e.g. 16_16sdp resource bucket).

Primary axes

Method family Scales by
Sdp / Sdpa / Sdpi / Sdpia Smallest width (+ AR / multi-window)
Hdp / Hdpa / … Screen height
Wdp / Wdpa / … Screen width

Inverter shortcuts (orientation-aware)

Example Typical behaviour
SdpPh / SdpPha Smallest width → height in portrait
SdpLw / SdpLwa Smallest width → width in landscape
HdpLw / HdpLwa Height → width in landscape
WdpLh / WdpLha Width → height in landscape

Each base method has matching a / i / ia variants where applicable.

Resource IDs (XML or GetDimension)

int padRes = DimenSdp.SdpRes(this, 16);
float padPx = Resources!.GetDimension(padRes);

// Or generic qualifier path:
int resId = DimenSdp.GetResourceId(this,
    Com.Appdimens.Sdps.Common.DpQualifier.SmallWidth, 16,
    Com.Appdimens.Sdps.Common.Inverter.None);

float px = DimenSdp.GetDimensionInPx(this,
    Com.Appdimens.Sdps.Common.DpQualifier.SmallWidth, 16,
    Com.Appdimens.Sdps.Common.Inverter.None,
    ignoreFontScale: false);

*Res helpers exist for inverter variants (SdpPhRes, HdpLwRes, …).

Facilitators (conditional layout)

using Com.Appdimens.Sdps.Code;
using Com.Appdimens.Sdps.Common;

float pad = DimenSdp.SdpRotate(this, 16, 24);
float padLandscape = DimenSdp.SdpRotate(this, 16, 24, Orientation.Landscape);

// Already-resolved px values (no second resource pass):
float plain = DimenSdp.SdpRotatePlain(this, 48f, 72f, Orientation.Landscape);

float tvPad = DimenSdp.SdpMode(this, 16, 24, UiModeType.Television);
float tablet = DimenSdp.SdpQualifier(this, 16, 20, DpQualifier.SmallWidth, 600);
float fold = DimenSdp.SdpScreen(this, 16, 28,
    UiModeType.Television, DpQualifier.SmallWidth, 600);

HdpRotate, WdpMode, HdpScreen, etc. mirror the HDP / WDP families.

DimenScaled builder (layout)

Priority-ordered rules — first match wins (not the same as nested extension order):

var chain = DimenSdp.Scaled(16)
    .Screen(UiModeType.Television, DpQualifier.SmallWidth, 600, 40)
    .Screen(UiModeType.Television, 32)
    .Screen(Orientation.Landscape, 20);

float px = chain.Sdp(this);
float heightPx = chain.Hdp(this);

Explore generated Screen(...) overloads on DimenScaled for qualifiers, inverters, and foldables.


Typography (DimenSsp)

Same conceptual model as layout, but for sp buckets (_16ssp, _32hsp, …).

Primary axes

Method Scales by
Ssp / Sspa / Sspi / Sspia Smallest width
Hsp / Hspa / … Height
Wsp / Wspa / … Width

Accessibility (ignore font scale)

Method Use when
Sem / Sema / … Smallest-width curve, fixed vs user font scale
Hem / Hema / … Height axis, fixed scale
Wem / Wema / … Width axis, fixed scale

Resource IDs

int textRes = DimenSsp.SspRes(this, 16);
float textPx = DimenSsp.Ssp(this, 16);

float lowLevel = DimenSsp.GetDimensionInSpPx(this,
    DpQualifier.SmallWidth, 16, Inverter.None, ignoreFontScale: false);

Facilitators & ScaledSp builder

float rotated = DimenSsp.SspRotate(this, 16, 24, ignoreFontScale: false);
float plain = DimenSsp.SspRotatePlain(this, 42f, 56f, Orientation.Landscape);

var textChain = DimenSsp.Scaled(16)
    .Screen(UiModeType.Television, DpQualifier.SmallWidth, 600, 40)
    .Screen(Orientation.Landscape, 20);

float titlePx = textChain.Ssp(this);
float fixedPx = textChain.Sem(this);   // ignore font scale

HspRotate, WspMode, SspScreen, etc. complete the HSP / WSP surface.


XML layouts (bundled resources)

Use dimens directly in Android XML / MAUI Android layouts:

<LinearLayout
    android:padding="@dimen/_16sdp"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <TextView
        android:layout_width="@dimen/_200wdp"
        android:layout_height="@dimen/_48hdp"
        android:textSize="@dimen/_18ssp"
        android:lineSpacingExtra="@dimen/_4ssp" />
</LinearLayout>

Naming pattern: _<n>sdp, _<n>hdp, _<n>wdp, _<n>ssp, _<n>hsp, _<n>wsp (and sem / hem / wem variants where generated). Values 1–600 are pre-calculated per qualifier bucket inside the AAR.


Aspect ratio & warmup

Sdpa, Sspa, Hdpa, … apply an aspect-ratio multiplier on top of the XML-resolved size (aligned with appdimens-dynamic when the same bucket is selected).

DimenSdp.WarmupSdpsFactors(this);

float layout = DimenSdp.Sdp(this, 32);
float layoutAr = DimenSdp.Sdpa(this, 32);

float text = DimenSsp.Ssp(this, 16);
float textAr = DimenSsp.Sspa(this, 16);

Factors live in Com.Appdimens.Sdps.Core.AppDimensSdpsFactors and invalidate when screen geometry or density changes.


Physical units

Com.Appdimens.Sdps.Code.DimenPhysicalUnits converts real-world units using display metrics:

float dpFromMm = DimenPhysicalUnits.ToDpFromMm(10f, Resources);
float pxFromCm = DimenPhysicalUnits.ToPxFromCm(2f, Resources);
float spFromInch = DimenPhysicalUnits.ToSpFromInch(0.25f, Resources);

Also: unit conversions (MmToCm, InchToMm, …) and geometry helpers (RadiusFromDiameter, …).


Shared types (Com.Appdimens.Sdps.Common)

Type Purpose
DpQualifier SmallWidth, Width, Height, …
DpQualifierEntry Qualifier + threshold for builders
Inverter Axis inversion for low-level resolution
Orientation Portrait / landscape facilitators
UiModeType TV, automotive, watch, …
UnitType Physical unit enums

Custom entries

CustomDpEntry and CustomSpEntry (in Com.Appdimens.Sdps.Code) support advanced builder/custom bucket scenarios exposed by the upstream library. Inspect generated members or upstream docs when you outgrow static Sdp/Ssp helpers.


Jetpack Compose (com.appdimens.sdps.compose)

The AAR includes Compose extensions (16.sdp, 18.ssp, scaledSp(), facilitators, …) that require androidx.compose.runtime.Composer. With the current class-parse binding pipeline, usable C# wrappers for most Compose helpers are not generated.

Recommended for .NET:

  • Com.Appdimens.Sdps.Code — Activities, Fragments, custom views, MAUI Android handlers
  • XML @dimen/_Nsdp / _@dimen/_Nssp in layout resources
  • DimenScaled / DimenSsp.Scaled builders from C#

Dependencies brought in by this package

NuGet Role
Xamarin.Kotlin.StdLib Kotlin runtime
Xamarin.AndroidX.Core Core / resources
Xamarin.AndroidX.Window Foldables (FoldingFeature)
Xamarin.AndroidX.Lifecycle.Runtime Lifecycle alignment with upstream AAR

Package version vs embedded AAR

Layer Version
Maven / embedded .aar appdimens-sdps 3.1.7
NuGet 3.6.0net10.0-android and updated Xamarin AndroidX; Android binary 3.1.7

When Maven publishes a new version, run ./scripts/sync-aar-from-maven.sh <maven-version> and bump the NuGet version accordingly.


Build this binding locally

cd appdimens-sdps-net-binding
dotnet build AppDimens.Sdps.sln -c Release

Smoke test: AppDimens.Sdps.SmokeTest — produce an APK with:

dotnet publish AppDimens.Sdps.SmokeTest/AppDimens.Sdps.SmokeTest.csproj -c Release -f net10.0-android -p:AndroidPackageFormat=apk

Sync the upstream AAR:

./scripts/sync-aar-from-maven.sh 3.1.7

Package Focus
Bodenberg.AppDimens.Ssps Typography only (SSP/HSP/WSP) — smaller dependency if you do not need sdp/hdp/wdp XML
Bodenberg.AppDimens.Dynamic Code-only scaling — 15 strategies, no pre-built @dimen grids

Resource URL
AppDimens (main project — NuGet Project website) https://github.com/bodenberg/appdimens
Android library (NuGet Source repository; implementation & issues) https://github.com/bodenberg/appdimens-sdps
Maven Central https://central.sonatype.com/artifact/io.github.bodenberg/appdimens-sdps
.NET binding monorepo https://github.com/bodenberg/appdimens-net-binding

License

Apache 2.0, consistent with the upstream library.

Product Compatible and additional computed target framework versions.
.NET net10.0-android36.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
3.6.0 93 8/23/2026
3.5.1.4 122 5/17/2026
3.5.1.3 108 5/17/2026
3.5.1.2 99 5/16/2026
3.1.5.1 126 5/16/2026
3.1.5 114 5/16/2026

NuGet 3.6.0: Embedded AAR Maven io.github.bodenberg:appdimens-sdps 3.1.7; multi-target
     net8.0-android / net9.0-android / net10.0-android / net11.0-android; SdpsConfig helper for
     warmup and configuration-change dimension refresh; AndroidX/Kotlin pins aligned to AAR POM.
     Android library: https://github.com/bodenberg/appdimens-sdps · Binding: https://github.com/bodenberg/appdimens-net-binding