All screens and components now have preview functions that allow you to view them in Android Studio without running the app on a device!
- ✅ Full screen preview
- ✅ Category card component preview
- ✅ Full form preview with all input fields
- ✅ Empty state preview
- ✅ Medicine card component preview
- ✅ Full chat interface preview
- ✅ Notification list preview
- ✅ All screens in one place
- ✅ Individual component previews
- ✅ Color palette showcase
- ✅ Chat message bubbles
Open any of these files:
homescreen.ktAddMedicineScreen.ktinsightscreen.ktchatscreen.ktnotificationscreen.ktPreviewShowcase.kt(Best - shows all screens!)
- Look at the top-right corner of the editor
- Click on "Split" or "Design" button
- Or use keyboard shortcut:
Ctrl + Shift + P(Windows/Linux) orCmd + Shift + P(Mac)
- The preview will render on the right side
- You can scroll through multiple previews if available
- Click the ↻ Refresh button if preview doesn't load
- Open any file with
@Previewannotation - Click on the ⚡ Split button at the top right
- Click the
▶️ Play button in the preview panel - Select a device to run the preview interactively
app/src/main/java/com/runanywhere/startup_hackathon20/ui_screens/
├── homescreen.kt ← 2 previews
├── AddMedicineScreen.kt ← 1 preview
├── insightscreen.kt ← 2 previews
├── chatscreen.kt ← 1 preview
├── notificationscreen.kt ← 1 preview
└── PreviewShowcase.kt ← 9 previews! 🎉
| Preview Name | File | Shows |
|---|---|---|
HomeScreenPreview |
homescreen.kt | Full home screen with categories |
CategoryCardPreview |
homescreen.kt | Individual category button |
AddMedicineScreenPreview |
AddMedicineScreen.kt | Medicine input form |
InsightsScreenEmptyPreview |
insightscreen.kt | Empty state message |
MedicineCardPreview |
insightscreen.kt | Medicine card with details |
ChatScreenPreview |
chatscreen.kt | Chat interface |
NotificationsScreenPreview |
notificationscreen.kt | Notification list |
| Preview Name | Shows |
|---|---|
PreviewHomeScreen |
Complete home screen |
PreviewAddMedicineScreen |
Add medicine form |
PreviewInsightsScreenEmpty |
Insights empty state |
PreviewChatScreen |
Chat interface |
PreviewNotificationsScreen |
Notifications |
PreviewMedicineCard |
Medicine card component |
PreviewNotificationCard |
Notification card |
PreviewChatMessageUser |
User chat bubble |
PreviewChatMessageBot |
Bot chat bubble |
PreviewColorPalette |
App color scheme |
@Preview(
showBackground = true, // Show white background
showSystemUi = true, // Show status bar and nav bar
name = "Screen Name" // Name in preview list
)
@Composable
fun MyScreenPreview() {
Startup_hackathon20Theme {
MyScreen()
}
}@Preview(
showBackground = true,
widthDp = 400, // Custom width
heightDp = 200, // Custom height
name = "Component Name"
)
@Composable
fun MyComponentPreview() {
Startup_hackathon20Theme {
MyComponent()
}
}@Preview(name = "Light Mode", showBackground = true)
@Preview(name = "Dark Mode", uiMode = UI_MODE_NIGHT_YES)
@Composable
fun MyPreview() {
// Preview content
}- Use the preview selector dropdown to switch between previews
- Group previews using
group = "Screens"parameter
@Preview(
showBackground = true, // White background
showSystemUi = true, // System UI (status bar, etc.)
widthDp = 360, // Device width
heightDp = 640, // Device height
name = "My Preview", // Preview name
group = "Screens" // Group name
)- Click the
▶️ Play button to run preview on emulator - Test interactions without full app launch
@Preview(name = "Phone", device = Devices.PIXEL_4)
@Preview(name = "Tablet", device = Devices.PIXEL_C)
@Composable
fun MultiDevicePreview() {
// Your composable
}-
Build the project first
./gradlew :app:assembleDebug
-
Refresh preview
- Click the ↻ Refresh button in preview panel
- Or use: Build → Refresh Preview
-
Invalidate caches
- File → Invalidate Caches → Invalidate and Restart
-
Check imports
- Make sure all required imports are present
- Preview functions need
@Previewannotation
-
Check theme
- Wrap preview in
Startup_hackathon20Theme { }
- Wrap preview in
-
Check parameters
- Preview functions should have no required parameters
- Use default values or mock data
-
Use Compose Preview only
- No need to build entire app
- Preview renders faster than full build
-
Disable unused previews
- Comment out
@Previewannotation - Reduces preview rendering time
- Comment out
The new PreviewShowcase.kt file includes:
- View all 5 main screens in one place
- Switch between previews easily
- See complete layouts
- Medicine cards
- Notification cards
- Chat message bubbles
- Form inputs
- All app colors displayed
- Hex codes shown
- Easy reference for design
- User messages (green gradient)
- Bot messages (white)
- Proper alignment and styling
- Open
PreviewShowcase.kt - Click Split mode (top-right)
- Scroll through all previews
- Click dropdown to select specific preview
- Open the screen file (e.g.,
homescreen.kt) - Enable Design mode
- See the screen instantly!
- Open any preview
- Click
▶️ Play in preview panel - Select device
- Interact with the preview
- No need to run app on device
- Instant visual feedback
- Quick iterations
- See UI before running
- Compare variations side-by-side
- Check all screen states
- Spot layout issues immediately
- Test different data states
- Verify responsive design
- Preview on different screen sizes
- Test tablet layouts
- Check phone variations
- Add previews to all
@Composablefunctions - Use descriptive names
- Group related previews
- Include edge cases (empty, loading, error states)
All screens now have complete preview support:
- ✅ 5 main screens with full previews
- ✅ 10+ component previews
- ✅ Color palette showcase
- ✅ Interactive preview support
- ✅ Multiple preview variations
- ✅
PreviewShowcase.ktfor everything in one place
Happy Previewing! 🎨