Last active
December 16, 2017 14:46
-
-
Save adavis/ca1fbbd0534230d10a655f172705f188 to your computer and use it in GitHub Desktop.
Implementation of the createView method for a Sample Anko Component
This file contains 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
override fun createView(ui: AnkoContext<PlanetDetailFragment>): View { | |
return with(ui) { | |
val container = verticalLayout { | |
lparams(matchParent) | |
textView { | |
setLineSpacing(8f, 1f) | |
}.lparams { | |
topMargin = dip(16) | |
} | |
textView { | |
setCompoundDrawablesWithIntrinsicBounds( | |
R.drawable.ic_landscape, 0, 0, 0) | |
} | |
textView { | |
setCompoundDrawablesWithIntrinsicBounds( | |
R.drawable.ic_brightness, 0, 0, 0) | |
} | |
textView { | |
setCompoundDrawablesWithIntrinsicBounds( | |
R.drawable.ic_loop, 0, 0, 0) | |
} | |
} | |
container.applyRecursively { view -> | |
when (view) { | |
is TextView -> { | |
with(view) { | |
padding = dip(16) | |
compoundDrawablePadding = dip(16) | |
layoutParams.width = matchParent | |
setTextIsSelectable(true) | |
textAppearance = R.style.TextAppearance_AppCompat_Medium | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment