Building a UI with CardView and ScrollView
Create a new project in the usual way. Name the project CardView Layout
. Leave the Target Android Devices section on the default settings and choose the Empty Activity project template. On the Configure Activity screen, uncheck the option to Generate Layout File because we will handle that ourselves. The activity name can be left as the default of MainActivity. The following screenshot shows these final settings:
To be able to edit our theme and properly test the result, we need to generate our layout file and edit the Java code to display it by calling the setContentView
method from the onCreate
method. We will design our CardView
masterpiece inside a ScrollView
layout, which, as the name suggests, allows the user to scroll through the content of the layout.
Expand the folders in the project explorer window so you can see the res
folder. Expand the res
folder and you will notice that there is no layout
folder. It is perfectly possible to build an...