A debug library that overlays the class names of the current Activity and Fragment on the screen.
ScreenNameViewer overlays class names directly on the screen, allowing you to instantly identify the currently visible Activity or Fragment.
This makes it easier to locate the corresponding code, speeding up debugging and improving development efficiency.
- Real-time class name display: Shows Activity and Fragment class names on screen in real-time
- Automatic lifecycle management: Automatically tracks all Activities and Fragments at the Application level
- Debug-only: Automatically disabled in release builds for safety
- UI customization: Freely configure text size, color, position, etc.
- Memory safe: Prevents memory leaks using WeakReference
- Touch interaction: Touch overlay to show full class name in toast
Add the Jitpack repository to your project's settings.gradle.kts:
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven { url = uri("https://jitpack.io") }
}
}Add the library to your module's build.gradle.kts:
dependencies {
implementation 'com.github.DongLab-DevTools:ScreenNameViewer:latestVersion'
}- Android API 21 (Android 5.0) or higher
Set up once and all Activities and Fragments will be automatically tracked:
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
initScreenNameViewer(this) {
settings {
debugModeCondition = BuildConfig.DEBUG
enableCondition = PreferenceManager.getDefaultSharedPreferences(this@MyApplication)
.getBoolean("debug_overlay_enabled", true)
}
config {
textStyle {
size = 12f
color = Color.WHITE
}
background {
color = Color.argb(128, 0, 0, 0)
padding = 16
}
position {
topMargin = 64
activity = Gravity.TOP or Gravity.START
fragment = Gravity.TOP or Gravity.END
composeRoute = Gravity.TOP or Gravity.END
}
}
}
}
}You can configure the library using a simple DSL (Domain Specific Language):
initScreenNameViewer(this) {
settings {
debugModeCondition = BuildConfig.DEBUG
enableCondition = PreferenceManager
.getDefaultSharedPreferences(this@MyApplication)
.getBoolean("debug_overlay_enabled", true)
}
config {
textStyle {
size = 12f // Text size
color = Color.WHITE // Text color
}
background {
color = Color.argb(128, 0, 0, 0) // Background color
padding = 16 // Padding
}
position {
topMargin = 64 // Top margin
activity = Gravity.TOP or Gravity.START // Activity display position
fragment = Gravity.TOP or Gravity.END // Fragment display position
composeRoute = Gravity.TOP or Gravity.END // Compose Route display position
}
}
}-
settings: Configure activation conditions
debugMode: Debug mode conditionenabled: Overlay feature activation condition
-
config: Customize overlay appearance
textStyle: Text size and colorbackground: Background color and paddingposition: Margin and display positions for different components
|
Donghyeon Kim |
JUNWON LEE |
