Resources & Configuration Interview Questions
ANDROID › System
How does Android choose resources for different devices, like different screen sizes, languages or dark mode?
What a strong answer covers: Resources live in folders with qualifiers like values-fr, values-night, layout-sw600dp or drawable-xxhdpi. At runtime the system picks the best match for the current configuration (locale, night mode, smallest width, density, orientation), using a defined precedence order, and falls back to the default folder. That's why every resource must exist in the unqualified folder.
What are dp and sp, and why shouldn't you use px for layouts?
What a strong answer covers: dp (density-independent pixels) scales with screen density so a 48dp button is the same physical size on every device. sp scales with density and with the user's font size setting, so text respects accessibility preferences. px is raw device pixels and looks tiny on dense screens.
How do you support dark theme properly?
What a strong answer covers: Use a DayNight or Material 3 theme and refer to colours through theme attributes (colorSurface, colorOnSurface) instead of hard-coded colours, with values-night overrides. In Compose, use MaterialTheme.colorScheme with darkColorScheme and dynamic colour on Android 12+. Test images and illustrations, status and navigation bar contrast, and don't rely on forceDark.
How do you handle localisation well: plurals, formatting and right-to-left layouts?
What a strong answer covers: Use string resources with placeholders (%1$s) so translators can reorder; plurals resources for quantity because languages have different plural rules; format dates, numbers and currency with locale-aware formatters; use start and end instead of left and right and set supportsRtl so layouts mirror; test with pseudo-locales (en-XA, ar-XB). Android 13 added per-app language preferences.
A designer wants a layout that looks right on phones, foldables and tablets. How do you approach this with resources or Compose window size classes?
What a strong answer covers: Design for window size classes (compact, medium, expanded) rather than devices, because the window can change size with multi-window and folding. In Compose, compute currentWindowAdaptiveInfo() and switch between layouts like a navigation bar vs rail vs drawer and list vs list-detail; with Views use sw600dp/w840dp resource qualifiers. Respond to configuration changes rather than locking orientation, handle fold postures with Jetpack WindowManager, and test on resizable emulators.