반응형
안드로이드에서 앱 구현 중, 다음과 같이 툴팁 메시지 창이 필요한 경우가 있습니다.
라이브러리를 통해 해당 기능을 구현해보도록 하겠습니다.
자세한 내용은 아래 링크를 통해 확인 부탁드립니다.
https://github.com/skydoves/Balloon
GitHub - skydoves/Balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android.
:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android. - GitHub - skydoves/Balloon: Modernized and sophisticated tooltips, fully customizable ...
github.com
implementation "com.github.skydoves:balloon:1.4.7"
앱 수준의 build.gradle에 다음과 같이 기입 후, sync 해줍니다.
val balloon = Balloon.Builder(this)
.setWidthRatio(0.2f)
.setHeight(BalloonSizeSpec.WRAP)
.setText("Today")
.setTextColorResource(R.color.white)
.setTextSize(13f)
.setIconDrawableResource(R.drawable.ic_launcher_background)
.setArrowPositionRules(ArrowPositionRules.ALIGN_ANCHOR)
.setArrowSize(10)
.setArrowPosition(0.5f)
.setPadding(10)
.setCornerRadius(8f)
.setBackgroundColorResource(R.color.black)
.setBalloonAnimation(BalloonAnimation.FADE)
.build()
이제 코틀린 코드 레벨에서 각 세부 기능에 해당하는 메서드를 통해
Balloon 객체를 구현할 수 있습니다.
textView.setOnClickListener{
balloon.showAlignTop(it)
balloon.dismissWithDelay(1000L)
}
Balloon 객체의 showAlign~(view: View)를 통해 어느 오브젝트에 해당 메시지를 팝업시킬 것인지 지정 가능하며,
몇 초 후에 해당 메시지를 dismiss 시킬 것인지 또한 설정 가능합니다.
반응형