Join Chiu-Ki Chan for an in-depth discussion in this video RecipeActivity: Layout, part of Effective Android Testing for Mobile Developers.
- [Narrator] Our Recyclerview shows the title of each recipe. Let's add an activity to our app so that we see the description for the recipe when we click on the title. First, let's make the layout file. Copy and paste activity_main.xml into activity_recipe.xml Instead of the top level Recyclerview we will need to change it so that we have a linear layout containing a title and description both text views.
And then, we can do rep the whole layout linear layout in a scroll view so that if the recipe is very long we can scroll to look at the whole recipe. Change the top level tech to scrollview. At the last line, add the name tag so that we can add linear layout inside. Since this is no longer a text view, delete the line in line nine for the text. Instead, we are going to add an attribute called android: fillviewport, set it to true so that if the recipe is short it will still fill up the whole screen.
Inside the scroll view, we are going to add a linear layout. Give it a width of match_parent and height of wrap_content. We will also need to set the orientation to vertical. Inside, we will be putting two text views. The first one is going to be for the title with width match_parent and height wrap_content. Add an id tag @+id title Since this is the title we will want it to be a bit bigger so we will add a text size to be 24sp.
Copy and past this whole Textview from line 15 to 19 and paste it so that we can use it for description In line 21 change the id to description. We want to at least to look a little bit smaller so, in line 24 change the Textsize to be 16. Finally, we want a little bit of space between the Textview for the title and the description. So, go back to line 18 and add a parameter called Layout_marginbottom.
We will set it to 8dp. Next, we are going to use this layout file to create recipe activity.
- Why test?
- Local vs. on-device
- Code coverage
- UI testing
- Hermetic environment
- Dependency injection
- Testing with MVP
Skill Level Intermediate
Android App Development: Unit Testingwith James P White2h 58m Intermediate
Android Studio Essential Trainingwith David Gassner3h 41m Beginner
Android App Development: Data Persistence Librarieswith Annyce Davis4h 52m Intermediate
1. Testing Considerations
2. Test as You Go
3. UI Testing
4. Hermetic Environment
5. Robot Pattern
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.