As we saw, RecyclerView is more effective than ListView, so I prefer to use it in my project. But recently I have a trouble when put it in my custom ViewGroup. RecyclerView
You can do it without inflating an XML layout, but you'll need to declare a custom theme attribute and a style:
Then set the value of the attribute to the style in your theme:
Now you can create the RecyclerView programmatically with a vertical scrollbar:
RecyclerView recyclerView = new RecyclerView(context, null, R.attr.verticalRecyclerViewStyle);