android_learning:headfirst_android_development_notes:chapter_5
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
android_learning:headfirst_android_development_notes:chapter_5 [2016/01/24 00:35] – 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%> | ||
- | Under development. | ||
- | </ | ||
- | |||
====== Chapter 5 notes ====== | ====== Chapter 5 notes ====== | ||
Line 33: | Line 29: | ||
===== pp. 174 ===== | ===== pp. 174 ===== | ||
- | Create a new project called " | + | Create a new project called " |
- Open '' | - Open '' | ||
Line 47: | Line 43: | ||
Make sure the attribute you add to the Button is **'' | Make sure the attribute you add to the Button is **'' | ||
- | <WRAP center round tip 100%> | + | <WRAP center round tip 90%> |
- | **What' | + | **What' |
* '' | * '' | ||
* '' | * '' | ||
Line 54: | Line 50: | ||
</ | </ | ||
- | ===== Additional notes ===== | + | 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 |
- | After all this, you might be wondering why you don't just use the drag-and-drop UI builder on the " | + | |
- | | + | |
- | | + | |
+ | - 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.1453595716.txt.gz · Last modified: 2016/01/24 00:35 by mithat