Sunday, March 10, 2019

Android开发笔记-ch3.2.7 Tab View, 3.2.8 Bar: Action, System, Status, 3.29 Navigation

3.2.7 Tab view

Refer to ViewPager, swipe view, TabHost/TabWidget/FragmentTabHost, ViewSwitcher and TabLayout. ViewSwitcher allows user to switch between two views. For legacy way, TabHost is the main container of tab view, TabWidget is used to navigate between tabs, and FrameLayout is used for tab content. According to this SO, using ViewPager with framents, will give a fresh and distinctive feel to the app, which are complicated but great in terms of performance and are replacable. TabHost is the old way, and in favour of FragmentTabHost, TabActivity has been deprecated. TabHost does not support Swipe view, but ViewPager does.
Regarding TabLayout, refer to this androidhive post. The old androidhive post about Tab Layout has many deprecated method. When using TabLayout, need add the Android Support Design lib, otherwise will get java.lang.ClassNotFoundException of android.support.design.widget.TabLayout.

3.2.8 Bar: Action, System, Status etc

TabView mostly will combine with ActionBar. Refer to actionbar. Refer to the right for about split action bar: When splitting up content across multiple action bars, you generally have three possible locations for action bar content:
  1. Main action bar
  2. Top bar
  3. Bottom bar
If the user can navigate up the hierarchy from a given screen, the main action bar contains the up caret, at a minimum. To allow the user to quickly switch between the views your app provides, use tabs or a spinner in the top bar. To display actions and, if necessary, the action overflow, use the bottom bar.
According to this: Split action bar provides a separate bar at the bottom of the screen. This option will be useful when you want to display the action items at the bottom of the screen by leaving some space on the title bar. To enable it, add uiOptions=”splitActionBarWhenNarrow” to all the <activity> tags or to the <application> tag directly in AndroidManifest.xml file. Also we need to add <meta-data> with the value android.support.UI_OPTIONS to support older version below API level 14.
ActionBar style can be generated with 'Android Action Bar Style Generator' (refer to SDK sample ActionBarCompat-Styled): http://jgilfelt.github.io/android-actionbarstylegenerator
For difference of bars, refer to SO1, SO2 and Google material, where the System bar in above picture is 
called navigation bar.

3.2.9 NavigationView vs. NavigationDrawerFragment

Eclipse/ADT wizard generates project with navigation drawer support is using NavigationDarwerFragment. Android Studio is following Google's latest design guide by using NavigationView, which may combine with ActinBarDrawerToggle (a button with three line icon on top-left, aka hamburger icon). This SO one mentioned the toggle is not a must any more. Cheesesquare sample is a good one. Without the toggle, there is no animation of the hamburger icon when open/close the drawer.
For adding a spinner to the NavigationDrawer, may need to refer to this SO, and this SO for using custom layout in NavigationView.

0 Comments:

Post a Comment