Skip to content

Instantly share code, notes, and snippets.

@gabrielbmoro
Created November 12, 2020 11:57
Show Gist options
  • Save gabrielbmoro/5db0d42da3d2ccac04f828be10af9c32 to your computer and use it in GitHub Desktop.
Save gabrielbmoro/5db0d42da3d2ccac04f828be10af9c32 to your computer and use it in GitHub Desktop.
Custom ViewGroup using a ConstraintLayout
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