android_learning:headfirst_android_development_notes:chapter_5
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
android_learning:headfirst_android_development_notes:chapter_5 [2016/01/09 01:07] – created mithat | android_learning:headfirst_android_development_notes:chapter_5 [2016/01/24 04:45] (current) – [Additional notes] mithat | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | <WRAP center round info 60%> | + | ====== Chapter 5 notes ====== |
- | Under development. | + | |
+ | ===== p. 167 ===== | ||
+ | If you fire up the Stopwatch app from the previous chapter, you'll see that Android Studio created a '' | ||
+ | |||
+ | <file xml dimens.xml> | ||
+ | < | ||
+ | <!-- Default screen margins, per the Android Design guidelines. --> | ||
+ | <dimen name=" | ||
+ | <dimen name=" | ||
+ | <dimen name=" | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | However, it looks like the padding values used in the RelativeLayout of '' | ||
+ | <file xml content_stopwatch.xml> | ||
+ | <?xml version=" | ||
+ | < | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | ... | ||
+ | </ | ||
+ | |||
+ | ===== pp. 174 ===== | ||
+ | Create a new project called " | ||
+ | |||
+ | - Open '' | ||
+ | - Replace the " | ||
+ | - Within the LinearLayout item, add the following attribute: <code xml> | ||
+ | |||
+ | Now you can add the new Views and other code presented through p.185. | ||
+ | |||
+ | ===== p. 181 ===== | ||
+ | Make sure the attribute you add to the EditText is **'' | ||
+ | |||
+ | ===== p. 183 ===== | ||
+ | Make sure the attribute you add to the Button is **'' | ||
+ | |||
+ | <WRAP center round tip 90%> | ||
+ | **What' | ||
+ | * '' | ||
+ | * '' | ||
+ | A Subtle, but important, distinction. | ||
</ | </ | ||
+ | |||
+ | But now we have a new problem: the email icon, which is actually part of a FloatingActionBar that Android Studio adds to all default projects, is covering the Send button. [[http:// | ||
+ | |||
+ | - In the '' | ||
+ | FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); | ||
+ | fab.setOnClickListener(new View.OnClickListener() { | ||
+ | @Override | ||
+ | public void onClick(View view) { | ||
+ | Snackbar.make(view, | ||
+ | .setAction(" | ||
+ | } | ||
+ | });</ | ||
+ | - In the '' | ||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | |||
+ | ===== p. 191 ===== | ||
+ | Create a new project to work with the GridLayout example. The process of converting the default RelativeLayout to a GridLayout is similar to changing it to a LinearLayout. Be sure to add an '' | ||
+ | |||
+ | ===== p. 193 ===== | ||
+ | When you create the EditText for the GridLayout example, add and remove the '' | ||
+ | |||
+ | ===== p. 205 ===== | ||
+ | Create a throwaway project for this final section of the chapter and experiment with as many of the Views covered as possible. | ||
+ | |||
+ | ===== p. 215 ===== | ||
+ | A good source of images that you can use without worrying about licensing is [[https:// | ||
+ | |||
+ | Another good resource is, [[https:// | ||
+ | |||
+ | <WRAP center round tip 90%> | ||
+ | **Be careful about file names.**\\ Image file names can only have lowercase letters, numbers, and the underscore in them. | ||
+ | </ | ||
+ | |||
+ | ===== p. 219 ===== | ||
+ | Your text suggest a ScrollView can be used as a root ViewGroup: | ||
+ | <file xml content_main.xml> | ||
+ | <?xml version=" | ||
+ | < | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | tools: | ||
+ | tools: | ||
+ | |||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | |||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | | ||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | ... | ||
+ | |||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | </ | ||
+ | |||
+ | However, in my experience this leads to unpredictable results (top of the ScrollView being obscured, etc.). A more reliable strategy seems to be nesting a ScrollView inside a root ViewGroups: | ||
+ | <file xml content_main.xml> | ||
+ | <?xml version=" | ||
+ | < | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | app: | ||
+ | tools: | ||
+ | tools: | ||
+ | |||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | |||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | |||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | | ||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | |||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | ... | ||
+ | |||
+ | < | ||
+ | android: | ||
+ | android: | ||
+ | android: | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | </ | ||
+ | </ | ||
+ | |||
+ | Android Studio produces a warning stating that the '' | ||
+ | |||
+ | <WRAP center round info 90%> | ||
+ | In the examples above, I am using string literals for the text attributes---only because this is throwaway, quick-n-dirty, | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Additional notes on the UI builder ===== | ||
+ | If you examine the UI builder on a layout' | ||
+ | |||
+ | Given that for a lot of people pointing, clicking, dragging, and dropping is more fun than writing code, you might be wondering why we didn't just use the drag-and-drop UI builder on the " | ||
+ | - Crawl before you walk. To use the UI builder effectively, | ||
+ | - The UI builder only gets you so far. Typically you need to change the code that the UI builder generates for you. So you need to know what the code does. |
android_learning/headfirst_android_development_notes/chapter_5.1452301634.txt.gz · Last modified: 2016/01/09 01:07 by mithat