![]() ![]() I have tried a lot of different layouts: having a NestedScrollView with an LinearLayout inside that contains both elements, a RelativeLayout, a ConstraintLayout. Right now in my App, when the user scrolls only the RecyclerView scrolls. When the user scrolls, the two elements scrolls, as shown here: Scrolled goal. Goal, where the orange line is the CardView and the yellow one the RecyclerView. ![]() So, when the user scrolls horizontally, I want the two elements to scroll. Public class RecyclerAdapter extends RecyclerView.I have a horizontal ScrollView that has two elements: a CardView and a horizontal RecyclerView. Rather than create a separate class to provide the data to be displayed, some basic arrays will also be added to the adapter to act as the data for the app: package In the Create New Class dialog, enter RecyclerAdapter into the Name: field and change the Kind menu to Class before clicking on the OK button to create the new Java class file.Įdit the new RecyclerAdapter.java file to add some import directives and to declare that the class now extends RecyclerView.Adapter. ![]() Add this new class to the project by right-clicking on the app -> java -> entry in the Project tool window and selecting the New -> Java Class menu option. ![]() Load the content_card_layout.xml file into the Layout Editor tool, switch to Text mode and modify the layout so that it reads as follows: Īs outlined in the previous chapter, the RecyclerView needs to have an adapter to handle the creation of the list items. In the New Resource Dialog enter card_layout into the File name: field and 7.widget.CardView into the root element field before clicking on the OK button. Within the Project tool window right-click on the app -> res -> layout entry and select the New -> Layout resource file menu option. The layout of the views contained within the cards will be defined within a separate XML layout file. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |