Skip to content

一个帮助你通过Kotlin代码快速布局的库

Notifications You must be signed in to change notification settings

UserName-Haha/LayoutDsl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Layout_DSL

使用Kotlin代码来动态构建布局,提升布局性能

class MainActivity : AppCompatActivity() {
    // build layout dynamically by DSL
    private val contentView by lazy {
        ConstraintLayout {
            layout_width = match_parent
            layout_height = match_parent

            TextView {
                layout_width = wrap_content
                layout_height = wrap_content
                text = "commit"
                textSize = 30f
                gravity = gravity_center
                center_horizontal = true
                top_toTopOf = parent_id
                padding = 10
            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        // set layout to content view
        setContentView(contentView)
    }
}

About

一个帮助你通过Kotlin代码快速布局的库

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages