Snackbar

2019. 12. 20. 15:10Kotlin

반응형
fun snackBar(view: View, message: String = "", position: Int = Gravity.BOTTOM
){
    val snack = Snackbar.make(view, message, Snackbar.LENGTH_LONG)
    val snackView = snack.view
    val params = snackView.layoutParams as (FrameLayout.LayoutParams)
    params.gravity = position
    params.width = FrameLayout.LayoutParams.MATCH_PARENT
    if(position == Gravity.TOP) 
       params.topMargin = 60
    snackView.layoutParams = params
    snack.show()
}
반응형

'Kotlin' 카테고리의 다른 글

zip, unzip  (0) 2019.12.20
Bitmap in putExtra  (0) 2019.12.20
BitmapFromAsset  (0) 2019.12.20
MVVM  (0) 2019.12.12
delegate  (0) 2019.12.11