首页 > 代码库 > 《Pro Android Graphics》读书笔记之第六节
《Pro Android Graphics》读书笔记之第六节
Android UI Layouts: Graphics Design Using the ViewGroup Class
Android ViewGroup Superclass: A Foundation for Layouts
The ViewGroup LayoutParams Class: Layout Parameters
Deprecated Layouts: AbsoluteLayout and SlidingDrawer
absoluteLayout 3 version 1.5
SlidingDrawer 17 version 4.2(DrawerLayout can replace)
Android’s Experimental Layout: SlidingPaneLayout
logical UI design usage of the SlidingPaneLayout container should include pairings of panes with logical use bindings. An example of this would be a phone number list with related dial or tagging features, a city or street list with related map features, a contact list and UI allowing interaction with the contact, or a recent e-mail list with a content pane displaying the message in the selected e-mail.
support the use of weight layout parameter android:layout_weight
Android RelativeLayout Class: Designing Relative Layouts
Android LinearLayout Class: Designing Linear Layouts
To set a weight, use a zero if the layout container is not to be stretched or use a decimal number between 0.0 and 1.0 to prorate any of those extra pixels amongst all of the UI elements (child tags) within the container.
Android FrameLayout Class: Designing Frame Layouts
注意:
It is important to note that child tags (View widgets) that are currently invisible because they’ve been specified via an Android View.GONE constant instead of using View.INVISIBLE will be utilized for FrameLayout container sizing purposes only if the .setConsiderGoneChildrenWhenMeasuring() method is called using a true parameter.
Android GridLayout Class: Designing UI Layout Grids
add in level 14
The Android Space class is a lightweight View subclass that can be used to create empty space between user interface elements in layout containers like GridLayout
does not currently provide support for the parameter called weight(如果需要,请使用LinearLayout)
you should not need to use either of the Android size value constants WRAP_CONTENT or MATCH_PARENT when you are configuring the child tags (UI elements) within your GridLayout container.
可以和数据库数据混合使用
比TableLayout更省内存
可以和FrameLayout结合,做出更复杂的效果
As I mentioned earlier, basic FrameLayout configurations can be nested and accommodated inside the cells of a GridLayout because a single cell can contain multiple View or ViewGroup objects.
To switch between two View or ViewGroup objects, you would place both of them into the same cell, and then leverage each via a visibility parameter by using the constant GONE in order to switch between one ViewGroup to the other ViewGroup (or View) from inside your Java code.
The DrawerLayout Class: Designing UI Drawer Layouts
package:android.support. v4.widget
android:layout_gravity
correspond to the side of the screen from which you want your UI Drawer to dragged out from
使用左右,而不能使用上下(Make absolutely sure not to use the TOP or BOTTOM (or any other constants) layout_gravity settings, as this class is not intended to provide vertical drawers, only horizontal ones, and will likely throw an exception.)
android:layout_height
match_parent
android:layout_width
you would next use the fixed width that you want to use for the UI Drawer width, specified using a DIP value
DrawerLayout.DrawerListener
Java code can do things when the drawer is open, closed, or being dragged.
onDrawerClosed(),onDrawerOpened(),onDrawerSlide(),onDrawerStateChanged()
STATE_IDLE
STATE_DRAGGING,STATE-SETTLING,LOCK_MODE_UNLOCKED,LOCK_MODE_LOCKED_OPEN,LOCK_MODE_LOCKED_CLOSED
DrawerLayout.SimpleDrawerListener
Adding Menu Items to Access the UI Layout Container
顺序(android:orderInCategory)