Created
November 12, 2020 11:57
-
-
Save gabrielbmoro/5db0d42da3d2ccac04f828be10af9c32 to your computer and use it in GitHub Desktop.
Custom ViewGroup using a ConstraintLayout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data class HeaderContent( | |
val headerText: String, | |
val subHeaderText: String, | |
val buttonText: String, | |
val buttonEvent: (()->Unit), | |
val isButtonVisible: Boolean, | |
val barEvent: (()->Unit) | |
) | |
class HeaderComponent @JvmOverloads constructor( | |
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 | |
) : ConstraintLayout( | |
context, attrs, defStyleAttr | |
) { | |
private var binding: ComponentHeaderBinding = DataBindingUtil.inflate( | |
LayoutInflater.from(context), R.layout.component_header, this, true | |
) | |
fun setContent(headerContent : HeaderContent) { | |
binding.setVariable(BR.headerContent, headerContent) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment