WebView Bottom Sheet is a clean, minimal demonstration of Android's powerful WebView component housed within a Material Design Bottom Sheet. It showcases how to elegantly integrate web content into your native Android app while maintaining a modern, user-friendly interface.
This project serves as a reference implementation for developers exploring the intersection of native Android development and web technologies.
Many Android developers struggle with:
- ✅ Seamlessly embedding web views
- ✅ Managing memory and lifecycle correctly
- ✅ Creating intuitive user interactions
- ✅ Maintaining native app feel
A beautifully crafted example demonstrating best practices for:
- 📱 Native-feeling UI — Bottom sheets slide smoothly from the bottom
- 🔄 Proper lifecycle management — WebView handles pause/resume/destroy correctly
- 🎨 Material Design 3 — Modern, polished aesthetics
- ⚡ Performance — Optimized memory and resource usage
- 🌐 Full web support — JavaScript, DOM, media playback enabled
Screen_recording_20260608_135102.webm
| Feature | Description |
|---|---|
| Material Design 3 | Modern Material You theming with custom colors |
| Bottom Sheet Dialog | Smooth, gesture-driven animations |
| Full WebView Support | JavaScript, DOM storage, zoom controls |
| Edge-to-Edge Display | Immersive UI experience |
| Proper Cleanup | Memory-efficient WebView destruction |
| Intercept Handling | Parent scroll intercept logic |
| Transparent Background | Clean visual integration |
- AndroidX Core — Foundation utilities
- Jetpack Compose — Modern UI toolkit
- Material 3 Components — Beautiful UI elements
- WebView — Full web rendering capabilities
- Fragment — Bottom sheet dialog support
- Android Studio — Arctic Fox 2020.3.1 or later
- JDK 17 — Required for compilation
- Android SDK — API 24+ (minSdk)
- Git — For cloning the repository
# Clone the repository
git clone https://github.com/kibotu/WebViewBottomSheet.git
cd WebViewBottomSheet
# Install dependencies
./gradlew dependencies
# Build debug APK
./gradlew assembleDebug
# Install on device
adb install app/build/outputs/apk/debug/app-debug.apkThe project uses:
- Kotlin DSL — Modern build scripting
- Gradle Caching — Optimized build times
- Daemon Enabled — Faster incremental builds
- Configuration Cache — Consistent builds across environments
- Connect your device or start an emulator
- Run the app:
./gradlew installDebug
./gradlew assembleReleaseNote: Release builds require signing configuration in
local.properties
# Install APK
adb install app/build/outputs/apk/debug/app-debug.apk
# Install and replace
adb install -r app/build/outputs/apk/debug/app-debug.apkMainActivity
├── StartScreen (Compose UI)
└── WebViewBottomSheetFragment (Bottom Sheet Dialog)
└── WebView (Full web rendering)
class WebViewBottomSheetFragment : BottomSheetDialogFragment() {
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog =
BottomSheetDialog(requireContext(), R.style.WebViewBottomSheet)
}web.settings.apply {
javaScriptEnabled = true
domStorageEnabled = true
loadWithOverviewMode = true
useWideViewPort = true
mediaPlaybackRequiresUserGesture = false
}override fun onDestroyView() {
webView?.apply {
stopLoading()
loadUrl("about:blank")
(parent as? ViewGroup)?.removeView(this)
destroy()
}
webView = null
}WebViewBottomSheet/
├── app/
│ ├── src/
│ │ └── main/
│ │ ├── java/net/kibotu/webviewbottomsheet/
│ │ │ ├── MainActivity.kt
│ │ │ └── WebViewBottomSheetFragment.kt
│ │ ├── res/
│ │ │ ├── layout/
│ │ │ │ └── fragment_webview_bottom_sheet.xml
│ │ │ ├── values/
│ │ │ │ ├── colors.xml
│ │ │ │ ├── strings.xml
│ │ │ │ └── themes.xml
│ │ │ └── xml/
│ │ │ ├── backup_rules.xml
│ │ │ └── data_extraction_rules.xml
│ │ └── keepRules/
│ │ └── rules.keep
│ └── build.gradle.kts
├── build.gradle.kts
├── settings.gradle.kts
└── gradle.properties
./gradlew test./gradlew connectedAndroidTest./gradlew lintThe app loads: https://trail.kibotu.net
This demonstrates a fully functional WebView with JavaScript and interactive content.
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- ✅ Kotlin idiomatic patterns
- ✅ Material Design guidelines
- ✅ Android best practices
- ✅ Clear, concise comments
Having issues or questions? Open an issue on GitHub.