Skip to content
This repository has been archived by the owner on Nov 14, 2018. It is now read-only.

View params casting extension using reified #473

Open
burhanrashid52 opened this issue Mar 29, 2018 · 0 comments
Open

View params casting extension using reified #473

burhanrashid52 opened this issue Mar 29, 2018 · 0 comments

Comments

@burhanrashid52
Copy link

burhanrashid52 commented Mar 29, 2018

Cast param extension function suggestion

inline fun <reified T : ViewGroup.LayoutParams> View.getParams() = this.layoutParams as T

Get get param like this

private lateinit var paramsGlHorizontal: ConstraintLayout.LayoutParams

override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        paramsGlHorizontal = guidelineHorizontal.getParams()
       
        val paramsGlVertical = guidelineVertical.getParams<ConstraintLayout.LayoutParams>()

}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant