Use EasyWindow in Java or Kotlin
masterYou can create floating windows using either an Activity or an Application object.
- Passing an Activity creates a local floating window (no overlay permission required).
- Passing an Application creates a global floating window (requires overlay permission).
Common configuration methods include setContentView, setWindowDuration, setWindowDraggableRule, and view-specific setters like setTextByTextView or setImageDrawableByImageView.
// Java Usage
EasyWindow.with(this)
.setContentView(R.layout.toast_hint)
.setWindowDuration(1000)
.setImageDrawableByImageView(android.R.id.icon, R.mipmap.ic_dialog_tip_finish)
.setTextByTextView(android.R.id.message, "Tap me to dismiss")
.setOnClickListenerByView(android.R.id.message, new OnWindowViewClickListener<TextView>() {
@Override
public void onClick(@NonNull EasyWindow<?> easyWindow, @NonNull TextView view) {
easyWindow.cancel();
}
})
.show();// Kotlin Usage
EasyWindow.with(activity).apply {
setContentView(R.layout.toast_hint)
setWindowDuration(1000)
setImageDrawableByImageView(android.R.id.icon, R.mipmap.ic_dialog_tip_finish)
setTextByTextView(android.R.id.message, "Tap me to dismiss")
setOnClickListenerByView(android.R.id.message, OnWindowViewClickListener<TextView?> { easyWindow, view ->
easyWindow.cancel()
})
}.show()