Guest User

Untitled

a guest
May 25th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. class ToolbarNBottombarTemplateLayout<A : Activity>(private val layoutInterface: ToolbarNBottombarTemplateLayoutInterface) : AnkoComponent<A> {
  2.  
  3. override fun createView(ui: AnkoContext<A>): View {
  4. return ui.constraintLayout {
  5.  
  6. val toolbar = themedToolbar(layoutInterface.toolbarStyleId())
  7. toolbar.layoutParams = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT,
  8. ConstraintLayout.LayoutParams.WRAP_CONTENT)
  9.  
  10. val included = include<View>(layoutInterface.includedLayoutId()) {
  11. id = View.generateViewId()
  12. }
  13.  
  14. val footer = themedTextView(layoutInterface.footerStyleId())
  15. footer.layoutParams = ConstraintLayout.LayoutParams(ConstraintLayout.LayoutParams.MATCH_PARENT,
  16. ConstraintLayout.LayoutParams.WRAP_CONTENT)
  17.  
  18. constraintSet {
  19. connect(toolbar.id,
  20. android.support.constraint.ConstraintSet.TOP,
  21. ConstraintSet.PARENT_ID,
  22. android.support.constraint.ConstraintSet.TOP)
  23.  
  24. connect(footer.id,
  25. android.support.constraint.ConstraintSet.BOTTOM,
  26. ConstraintSet.PARENT_ID,
  27. android.support.constraint.ConstraintSet.BOTTOM)
  28.  
  29. connect(included.id,
  30. android.support.constraint.ConstraintSet.TOP,
  31. toolbar.id,
  32. android.support.constraint.ConstraintSet.BOTTOM)
  33. connect(included.id,
  34. android.support.constraint.ConstraintSet.BOTTOM,
  35. footer.id,
  36. android.support.constraint.ConstraintSet.TOP)
  37. }.applyTo(this)
  38. }
  39. }
  40.  
  41. interface ToolbarNBottombarTemplateLayoutInterface {
  42. fun toolbarStyleId(): Int
  43. fun includedLayoutId(): Int
  44. fun footerStyleId(): Int
  45. }
  46. }
Add Comment
Please, Sign In to add comment