Create a custom View/ViewGroup class in Anko DSL

前端 未结 2 1016
我在风中等你
我在风中等你 2021-02-05 18:34

I want to create a custom View which is just a wrapper of some Android Views. I looked into creating a custom ViewGroup which manages the layout of it\'s child views, but I don\

2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 19:01

    you can use ViewManager.

    fun ViewManager.swipeLayout() = linearLayout {
      textView {
        text = "Some text"
      }
      textView {
        text = "Another text"
      }
    }
    

    class MainActivity
      verticalLayout {
        textView {
          text = "Something that comes above the swipe"
        }
        swipeLayout {}
    }
    

提交回复
热议问题