Skip to content

Instantly share code, notes, and snippets.

@krossovochkin
Created January 18, 2020 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krossovochkin/145ca7c5a696e25d78e5b26172765ecd to your computer and use it in GitHub Desktop.
Save krossovochkin/145ca7c5a696e25d78e5b26172765ecd to your computer and use it in GitHub Desktop.
Theme_1
class MyLayoutInflater(
private val delegate: AppCompatDelegate
) : LayoutInflater.Factory2 {
override fun onCreateView(
parent: View?,
name: String,
context: Context,
attrs: AttributeSet
): View? {
return when (name) {
"TextView" -> MyTextView(context, attrs)
"LinearLayout" -> MyLinearLayout(context, attrs)
"Button" -> MyButton(context, attrs, R.attr.buttonStyle)
else -> delegate.createView(parent, name, context, attrs)
}
}
override fun onCreateView(name: String, context: Context, attrs: AttributeSet): View? {
return onCreateView(null, name, context, attrs)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment