Created
January 12, 2020 03:45
-
-
Save seoft/13f7fa3bbd05e616f71a2d2ead6ff4d4 to your computer and use it in GitHub Desktop.
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
class ClickableRecyclerViewInCl @JvmOverloads constructor( | |
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 | |
) : ConstraintLayout(context, attrs, defStyleAttr) { | |
val rv = RecyclerView(context) | |
override fun onInterceptTouchEvent(ev: MotionEvent?): Boolean { | |
return true | |
} | |
init { | |
rv.id = View.generateViewId() | |
this.addView(rv) | |
ConstraintSet().also { cs -> | |
cs.clone(this) | |
cs.connect( | |
rv.id, | |
ConstraintSet.LEFT, | |
ConstraintSet.PARENT_ID, | |
ConstraintSet.LEFT, | |
0 | |
) | |
cs.connect( | |
rv.id, | |
ConstraintSet.TOP, | |
ConstraintSet.PARENT_ID, | |
ConstraintSet.TOP, | |
0 | |
) | |
cs.applyTo(this) | |
} | |
rv.layoutParams.apply { | |
width = LayoutParams.MATCH_PARENT | |
height = LayoutParams.MATCH_PARENT | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment