Last active
August 16, 2017 08:11
-
-
Save paraya3636/4093d9f1b0b53d69584d602b3184b9f6 to your computer and use it in GitHub Desktop.
KotlinCustomView constructor for Android
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
class KotlinCustomView | |
@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : View(context, attrs, defStyleAttr) | |
class KotlinCustomView: View { | |
// Basic constructors | |
constructor(context: Context) : super(context) | |
constructor(context: Context, attrs: AttributeSet) : super(context, attrs) | |
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle) | |
// There constructors style is no problem about…but, no apply padding, gravity… | |
constructor(context: Context) : this(context, null) | |
constructor(context: Context, attrs: AttributeSet?) : this(context, attrs, 0) | |
constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : super(context, attrs, defStyleAttr) | |
// For upper API Level 21 | |
constructor(context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0, defStyleRes: Int = 0): super(context, attrs, defStyleAttr, defStyleRes) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment