https://github.com/khaouitiabdelhakim/theme-showcase-android-kotlin
A simple Android app demonstrating light and dark theme implementation.
https://github.com/khaouitiabdelhakim/theme-showcase-android-kotlin
android android-application kotlin kotlin-android styles theme
Last synced: 7 months ago
JSON representation
A simple Android app demonstrating light and dark theme implementation.
- Host: GitHub
- URL: https://github.com/khaouitiabdelhakim/theme-showcase-android-kotlin
- Owner: khaouitiabdelhakim
- Created: 2025-03-08T10:09:13.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2025-03-08T10:41:10.000Z (7 months ago)
- Last Synced: 2025-03-08T11:19:46.546Z (7 months ago)
- Topics: android, android-application, kotlin, kotlin-android, styles, theme
- Language: Kotlin
- Homepage: https://khaouitiapps.com
- Size: 786 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Android Theme Showcase
A simple Android app demonstrating light and dark theme implementation.
## Theme Preview
→
## Features
- Toggle between light and dark themes
- Custom theme attributes
- Responsive UI elements
- Material Design components## Setup
1. Clone the repository
2. Open in Android Studio
3. Run on a device or emulator## Project Structure
- `attrs.xml` - Custom theme attributes
- `themes.xml` (in values) - Light theme configuration
- `themes.xml` (in values-night) - Dark theme configuration
- `MainActivity.kt` - Theme toggle implementation
- `activity_main.xml` - UI layout with theme-aware components## Key Concepts
- Using `?attr/` references for theme-aware styling
- Creating custom theme attributes
- Implementing theme switching with `AppCompatDelegate`
- Using resource directories (`values-night`) for theme variants
- Translucent status bar implementation## Implementation Notes
The theme toggle works by calling:
```kotlin
AppCompatDelegate.setDefaultNightMode(mode)
recreate() // Important to apply changes
```