Skip to content

Instantly share code, notes, and snippets.

@CodeK1988
Created July 23, 2019 02:59
Show Gist options
  • Select an option

  • Save CodeK1988/feedeaa2f37e8d12150a5fdff3c4718f to your computer and use it in GitHub Desktop.

Select an option

Save CodeK1988/feedeaa2f37e8d12150a5fdff3c4718f to your computer and use it in GitHub Desktop.
kotlin handsome code 集合
thanks:
https://medium.com/@rygel/stop-repeating-yourself-and-create-custom-views-on-android-with-kotlin-f5b3fc581c0e
https://medium.com/@elye.project/building-custom-component-with-kotlin-fc082678b080
https://medium.com/@mmlodawski/https-medium-com-mmlodawski-do-not-always-trust-jvmoverloads-5251f1ad2cfe
1.
constructor(context: Context) : super(context) {
init(context)
}
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) {
init(context)
}
constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
init(context)
}
2.
@JvmOverloads
constructor(context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : super(context, attrs, defStyleAttr)
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
constructor(context: Context,
attrs: AttributeSet?,
defStyleAttr: Int,
defStyleRes: Int
) : super(context, attrs, defStyleAttr, defStyleRes)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment