紧急避孕药和堕胎药:Android LinearLayout中文文档

来源:百度文库 编辑:偶看新闻 时间:2024/04/30 00:02:05
public class LinearLayout
extendsViewGroup
java.lang.Object
android.view.View
android.view.ViewGroup
android.widget.LinearLayout
已知直接子类RadioGroup,TabWidget,TableLayout,TableRow,ZoomControls
RadioGroup
这个类用于创建一组单选按钮之间多重排斥的范围.
TabWidget显示代表父选项卡集合中的选项卡的标签列表.
TableLayout
按照行列来组织子视图的布局.表格布局包含一系列的表格行对象,用于定义行(实际上你也可以使用其它子对象,将在后面进行解释).
TableRow
按照水平方向来组织子视图的布局。TableRow应该总是作为TableLayout.
ZoomControlsZoomControls 显示一组简单的控件集合用于缩放,并可以注册事件发生时执行的回调函数.
类概述
A Layout that arranges its children in a single column or a single row. The direction of the row can be set by callingsetOrientation(). You can also specify gravity, which specifies the alignment of all the child elements by callingsetGravity() or specify that specific children grow to fill up any remaining space in the layout by setting the weight member ofLinearLayout.LayoutParams. The default orientation is horizontal.
See theLinear Layout tutorial.
Also seeandroid.widget.LinearLayout.LayoutParams for layout attributes
摘要
嵌套类
classLinearLayout.LayoutParamsPer-child layout information associated with ViewLinearLayout.
XML 属性
属性名关联方法描述
android:baselineAlignedsetBaselineAligned(boolean) When set to false, prevents the layout from aligning its children's baselines.
android:baselineAlignedChildIndexsetBaselineAlignedChildIndex(int) When a linear layout is part of another layout that is baseline aligned, it can specify which of its children to baseline align to (that is, which child TextView).
android:gravitysetGravity(int) 指定在对象内部,横纵方向上如何放置对象的内容.
android:orientationsetOrientation(int) Should the layout be a column or a row? Use "horizontal" for a row, "vertical" for a column.
[展开] 继承的 XML 属性
来自 classandroid.view.ViewGroup
属性名关联方法描述
android:addStatesFromChildrenSets whether this ViewGroup's drawable states also include its children's drawable states.
android:alwaysDrawnWithCacheDefines whether the ViewGroup should always draw its children using their drawing cache or not.
android:animationCacheDefines whether layout animations should create a drawing cache for their children.
android:clipChildrensetClipChildren(boolean) Defines whether a child is limited to draw inside of its bounds or not.
android:clipToPaddingsetClipToPadding(boolean) Defines whether the ViewGroup will clip its drawing surface so as to exclude the padding area.
android:descendantFocusabilityDefines the relationship between the ViewGroup and its descendants when looking for a View to take focus.
android:layoutAnimationDefines the layout animation to use the first time the ViewGroup is laid out.
android:persistentDrawingCacheDefines the persistence of the drawing cache.
来自 classandroid.view.View
属性名关联方法描述
android:backgroundsetBackgroundResource(int) 作为背景使用的可绘制对象.它可以是对完整得可绘制对象资源 (比如:PNG 图像、9片图、XML 状态列表描述等等) 或者是象“#ff000000”(黑色)这样得纯色.
android:clickablesetClickable(boolean) 定义该视图是否响应点击事件.
android:contentDescriptionsetContentDescription(CharSequence) 定义对视图内容的简短描述.
android:drawingCacheQualitysetDrawingCacheQuality(int) 定义半透明缓存的质量.
android:duplicateParentState当该属性设为真时,视图从它的容器视图取得可绘制状态(比如得焦点状态、 按下状态、等),而不是使用它自己的状态..
android:fadingEdgesetVerticalFadingEdgeEnabled(boolean) 定义滚动时淡出的边.
android:fadingEdgeLengthgetVerticalFadingEdgeLength() 定义淡出边的长度.
android:filterTouchesWhenObscuredsetFilterTouchesWhenObscured(boolean) 指定当视图窗口被其他可视视图窗口遮挡时,是否过滤掉触控事件.
android:fitsSystemWindows布尔型内部属性,用于设置是否根据系统窗口(比如状态栏)来调整视图的布局.
android:focusablesetFocusable(boolean) 布尔值,用于控制视图是否可以获得焦点.
android:focusableInTouchModesetFocusableInTouchMode(boolean) 布尔值,用于控制在触控模式下视图是否可以获得焦点.
android:hapticFeedbackEnabledsetHapticFeedbackEnabled(boolean) 布尔值,控制发生诸如长按事件时,是否使用震动反馈.
android:idsetId(int) 为当前视图设置一个标识名,以后可以通过调用View.findViewById() 方法或Activity.findViewById() 方法来取得视图.
android:isScrollContainer如果视图作为滚动容器使用,将该值设为真; 这意味它可以缩小占用的空间,以为输入法提供显示的空间.
android:keepScreenOnsetKeepScreenOn(boolean) 定义视图窗口可见时,是否保持屏幕始终处于开启状态.
android:longClickablesetLongClickable(boolean) 定义该视图是否响应长按事件.
android:minHeight定义视图的最小高度.
android:minWidth定义视图的最小宽度.
android:nextFocusDownsetNextFocusDownId(int) 定义焦点移动为FOCUS_DOWN 时,下一个获得焦点的视图.
android:nextFocusLeftsetNextFocusLeftId(int) 定义焦点移动为FOCUS_LEFT 时,下一个获得焦点的视图.
android:nextFocusRightsetNextFocusRightId(int) 定义焦点移动为FOCUS_RIGHT 时,下一个获得焦点的视图.
android:nextFocusUpsetNextFocusUpId(int) 定义焦点移动为FOCUS_UP 时,下一个获得焦点的视图.
android:onClick单击视图时执行的视图上下文中的方法名.
android:paddingsetPadding(int,int,int,int) 以像素为单位设置四条边的内边距.
android:paddingBottomsetPadding(int,int,int,int) 以像素为单位设置下边的内边距.
android:paddingLeftsetPadding(int,int,int,int) 以像素为单位设置左边的内边距.
android:paddingRightsetPadding(int,int,int,int) 以像素为单位设置右边的内边距.
android:paddingTopsetPadding(int,int,int,int) 以像素为单位设置上边的内边距.
android:saveEnabledsetSaveEnabled(boolean) 如果取消该设置,冻结视图时不保存视图的任何状态信息.
android:scrollX以像数为单位的横向滚动条位置.
android:scrollY以像数为单位的纵向滚动条位置
一定是尺寸值,由浮点数后跟长度单位组成。比如“14.5sp”。可用单位有:px (像素)、dp (密度/设备无关像素)、sp (基于首选字体大小的缩放像素)、 in (英寸), mm (毫米).
android:scrollbarAlwaysDrawHorizontalTrack定义是否总是绘制横向滚动条滑道.
android:scrollbarAlwaysDrawVerticalTrack定义是否总是绘制纵向滚动条滑道.
android:scrollbarDefaultDelayBeforeFade以毫秒为单位定义淡出前等待时间.
android:scrollbarFadeDuration以毫秒为单位定义淡出所用时间.
android:scrollbarSize定义纵向滚动条的宽度和横向滚动条的高度.
android:scrollbarStyle控制滚动条的位置和样式.
android:scrollbarThumbHorizontal定义用于横向滚动条把手的可绘制对象.
android:scrollbarThumbVertical定义用于纵向滚动条把手的可绘制对象.
android:scrollbarTrackHorizontal定义用于横向滚动条滑道的可绘制对象.
android:scrollbarTrackVertical定义用于纵向滚动条滑道的可绘制对象.
android:scrollbars定义显示那个方向的滚动条.
android:soundEffectsEnabledsetSoundEffectsEnabled(boolean) 布尔值,控制发生诸如点击、触控事件时是否使用声效.
android:tag设置一个文本标签,以后可以通过调用View.getTag() 取得视图或者调用View.findViewWithTag() 来查找并取得视图.最好使用 ID(通过 android:id 属性定义)来代替 文本标签,因为它的速度更快,并且允许编译时类型检查.
android:visibilitysetVisibility(int) 控制视图的初始可视性.
常量
intHORIZONTAL
intVERTICAL
[展开] 继承的常量
来自 classandroid.view.ViewGroup
intCLIP_TO_PADDING_MASK当 FLAG_CLIP_TO_PADDING 和 FLAG_PADDING_NOT_NULL 同时设置时,绘图将剪切掉在内边距区域内的图像.
intFOCUS_AFTER_DESCENDANTS只有当没有子节点可以获得焦点时,该视图获得焦点.
intFOCUS_BEFORE_DESCENDANTSThis view will get focus before any of its descendants.
intFOCUS_BLOCK_DESCENDANTSThis view will block any of its descendants from getting focus, even if they are focusable.
intPERSISTENT_ALL_CACHESUsed to indicate that all drawing caches should be kept in memory.
intPERSISTENT_ANIMATION_CACHEUsed to indicate that the animation drawing cache should be kept in memory.
intPERSISTENT_NO_CACHEUsed to indicate that no drawing cache should be kept in memory.
intPERSISTENT_SCROLLING_CACHEUsed to indicate that the scrolling drawing cache should be kept in memory.
来自 classandroid.view.View
intDRAWING_CACHE_QUALITY_AUTO
为绘图缓存启用自动质量控制模式.
intDRAWING_CACHE_QUALITY_HIGH
为绘图缓存启用高质量控制模式.
intDRAWING_CACHE_QUALITY_LOW
为绘图缓存启用低质量控制模式.
int[]EMPTY_STATE_SET指出视图没有设置状态.
int[]ENABLED_FOCUSED_SELECTED_STATE_SET指出视图可用、具有焦点并已选中.
int[]ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET指出视图可用、具有焦点、已选中并且其窗口具有焦点.
int[]ENABLED_FOCUSED_STATE_SET指出视图可用并具有焦点.
int[]ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET指出视图可用、具有焦点并且其窗口也具有焦点.
int[]ENABLED_SELECTED_STATE_SET指出视图可用并已选中.
int[]ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET指出视图可用、已选中并且其窗口具有焦点.
int[]ENABLED_STATE_SET指出视图时可用的.Drawable 根据不同的状态变更视图的外观.
int[]ENABLED_WINDOW_FOCUSED_STATE_SET指出视图可用并且其窗口具有焦点.
intFOCUSABLES_ALL视图标志位,指出无论是否处于触控模式下,以及触控模式下是否可以获得焦点,, int, int)">addFocusables(ArrayList, int, int) 函数都会添加该视图.
intFOCUSABLES_TOUCH_MODE视图标志位,指出, int, int)">addFocusables(ArrayList, int, int) 函数只添加在触控模式下可以获得焦点的视图.
int[]FOCUSED_SELECTED_STATE_SET指出视图具有焦点并且已选中.
int[]FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET指出视图具有焦点、已选中并且其窗口具有焦点.
int[]FOCUSED_STATE_SET指出视图得到焦点.
int[]FOCUSED_WINDOW_FOCUSED_STATE_SET指出视图具有焦点并且其窗口也具有焦点.
intFOCUS_BACKWARD用于focusSearch(int).移动焦点到前一个可选择条目.
intFOCUS_DOWN用于focusSearch(int).向下移动焦点.
intFOCUS_FORWARD用于focusSearch(int).移动焦点到下一个可选择条目.
intFOCUS_LEFT用于focusSearch(int).向左移动焦点.
intFOCUS_RIGHT用于focusSearch(int).向右移动焦点.
intFOCUS_UP用于focusSearch(int).向上移动焦点.
intGONE视图不可见,并且不占用布局时的空间.用于setVisibility(int).
intHAPTIC_FEEDBACK_ENABLED视图标志位,指示发生诸如长按事件时视图是否执行震动反馈.
intINVISIBLE视图不可见,但为其保留布局时所占用的空间.用于setVisibility(int).
intKEEP_SCREEN_ON视图标志位,用于指明当窗口包含对用户可见的该视图时,屏幕应该一直处于开启状态.
intNO_ID用于识别没有 ID 的视图.
intOVER_SCROLL_ALWAYS总是允许用户过滚动该视图,用于可以滚动的视图.
intOVER_SCROLL_IF_CONTENT_SCROLLS允许用户对内容大于滚动区域的视图进行过滚动,用于可以滚动的视图.
intOVER_SCROLL_NEVER不允许用户对该视图进行过滚动.
int[]PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET指出视图可按下、可用、具有焦点并与选中.
int[]PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET指出视图已按下、可用、具有焦点并且其窗口具有焦点.
int[]PRESSED_ENABLED_FOCUSED_STATE_SET指出视图已按下、可用并具有焦点.
int[]PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET指出视图已按下、可用、具有焦点并且其窗口具有焦点.
int[]PRESSED_ENABLED_SELECTED_STATE_SET指出视图已按下、可用并且已选中.
int[]PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET指出视图已按下、可用、已选中并且其窗口具有焦点.
int[]PRESSED_ENABLED_STATE_SET指出视图已按下并可用.
int[]PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET指出视图已按下、可用并且其窗口具有焦点.
int[]PRESSED_FOCUSED_SELECTED_STATE_SET质粗视图已按下、具有焦点并已选中.
int[]PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET指出视图已按下、具有焦点、已选中并且其窗口具有焦点.
int[]PRESSED_FOCUSED_STATE_SET指出视图已按下并具有焦点.
int[]PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET指出视图已按下、具有焦点并且其窗口具有焦点.
int[]PRESSED_SELECTED_STATE_SET指出视图已按下并已选中.
int[]PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET指出视图已按下、已选中并且其窗口具有焦点.
int[]PRESSED_WINDOW_FOCUSED_STATE_SET指出视图已按下并且其窗口具有焦点.
intSCROLLBARS_INSIDE_INSET用于在内边距内显示滚动条的滚动条风格,增加视图的内边距.
intSCROLLBARS_INSIDE_OVERLAY用于在内容区域显示滚动条的滚动条风格,不增加内边距.
intSCROLLBARS_OUTSIDE_INSET用于在视图边上显示滚动条的滚动条风格,增加视图的内边距.
intSCROLLBARS_OUTSIDE_OVERLAY用于在视图边上显示滚动条的滚动条风格,不增加内边距.
int[]SELECTED_STATE_SET指出视图已选中.
int[]SELECTED_WINDOW_FOCUSED_STATE_SET指出视图已选中并且其窗口具有焦点.
intSOUND_EFFECTS_ENABLED视图标志位,指示发生诸如单击、触控事件时视图是否播放声音效果.
StringVIEW_LOG_TAG在该类中使用 android.util.Log 输出日志时的标签.
intVISIBLE视图可见.用于setVisibility(int).
int[]WINDOW_FOCUSED_STATE_SET指出视图的窗口具有焦点.
公有构造函数
LinearLayout(Context context)
LinearLayout(Context context,AttributeSet attrs)
公有方法
LinearLayout.LayoutParamsgenerateLayoutParams(AttributeSet attrs) 返回一组基于提供的属性集合的布局参数集合.
intgetBaseline()
返回小部件顶端到文本基线的偏移量.如果小部件不支持基线对齐,该方法返回 -1.
intgetBaselineAlignedChildIndex()
intgetOrientation() Returns the current orientation.
floatgetWeightSum() Returns the desired weights sum.
booleanisBaselineAligned()
Indicates whether widgets contained within this layout are aligned on their baseline or not.
voidsetBaselineAligned(boolean baselineAligned)
Defines whether widgets contained in this layout are baseline-aligned or not.
voidsetBaselineAlignedChildIndex(int i)
voidsetGravity(int gravity) Describes how the child views are positioned.
voidsetHorizontalGravity(int horizontalGravity)
voidsetOrientation(int orientation) Should the layout be a column or a row.
voidsetVerticalGravity(int verticalGravity)
voidsetWeightSum(float weightSum) Defines the desired weights sum.
保护方法
booleancheckLayoutParams(ViewGroup.LayoutParams p)
LinearLayout.LayoutParamsgenerateDefaultLayoutParams() 返回一组包含宽度和高度的布局参数的集合.当视图为纵向布局 (VERTICAL) 时,返回的宽度为MATCH_PARENT、 高度为WRAP_CONTENT.
LinearLayout.LayoutParamsgenerateLayoutParams(ViewGroup.LayoutParams p) 基于提供的布局参数返回一组安全的布局参数集合.当传入 ViewGroup 的视图的参数没有通过checkLayoutParams(android.view.ViewGroup.LayoutParams) 的检测时,调用该方法.
voidonLayout(boolean changed, int l, int t, int r, int b) 该视图设置其子视图的大小及位置时调用.派生类可以重写此方法,并为其子类布局.
voidonMeasure(int widthMeasureSpec, int heightMeasureSpec)
评估视图及其内容,以决定其宽度和高度.此方法由measure(int, int) 调用,子类可以重载以提供更精确、更有效率的衡量其内容尺寸的方法.
[展开] 继承的方法
来自 classandroid.view.ViewGroup
void, int, int)">addFocusables(ArrayList views, int direction, int focusableMode) Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views.
void, int)">addFocusables(ArrayList views, int direction) Add any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views.
booleanaddStatesFromChildren() Returns whether this ViewGroup's drawable states also include its children's drawable states.
void)">addTouchables(ArrayList views) 想views添加可触控视图,该可触控视图是该视图的后代(如果该视图可触控, 也可以添加该视图)。
voidaddView(View child, int index,ViewGroup.LayoutParams params) 用指定的布局参数添加一个子视图.
voidaddView(View child,ViewGroup.LayoutParams params) 使用指定的布局参数添加子视图.
voidaddView(View child, int index) 添加子视图.如果子视图没有设置布局参数,则使用视图组的布局参数为该视图布局.
voidaddView(View child) 添加子视图.如果子视图没有设置布局参数,则使用视图组的布局参数为该视图布局.
voidaddView(View child, int width, int height) 以指定的宽度和高度,以及视图组的默认布局参数添加子视图.
booleanaddViewInLayout(View child, int index,ViewGroup.LayoutParams params, boolean preventRequestLayout) Adds a view during layout.
booleanaddViewInLayout(View child, int index,ViewGroup.LayoutParams params) Adds a view during layout.
voidattachLayoutAnimationParameters(View child,ViewGroup.LayoutParams params, int index, int count) 子类应该重写该方法,以设置为子视图提供的布局动画参数.
voidattachViewToParent(View child, int index,ViewGroup.LayoutParams params) Attaches a view to this view group.
voidbringChildToFront(View child) 改变子视图的前后顺序,将其移动到所有视图的最前面。
booleancanAnimate() 指示视图组是否能够在首次布局后为其子视图提供动画效果的显示.
booleancheckLayoutParams(ViewGroup.LayoutParams p)
voidchildDrawableStateChanged(View child) 如果 {link #addStatesFromChildren} 为真,刷新该试图组的可绘制状态 (包括其子元素的状态)。
voidcleanupLayoutState(View child) Prevents the specified child to be laid out during the next layout pass.
voidclearChildFocus(View child) 当该视图的子视图需要放弃焦点时调用。
voidclearDisappearingChildren() Removes any pending animations for views that have been removed.
voidclearFocus() Called when this view wants to give up focus.
voiddebug(int depth) 在日志文件中使用VIEW_LOG_TAG标签输出关于该视图的信息。 每行输出都包含有depth指定的缩进。
voiddetachAllViewsFromParent() Detaches all views from the parent.
voiddetachViewFromParent(View child) Detaches a view from its parent.
voiddetachViewFromParent(int index) Detaches a view from its parent.
voiddetachViewsFromParent(int start, int count) Detaches a range of view from their parent.
voiddispatchConfigurationChanged(Configuration newConfig) Dispatch a notification about a resource configuration change down the view hierarchy.
voiddispatchDisplayHint(int hint) Dispatch a hint about whether this view is displayed.
voiddispatchDraw(Canvas canvas) 调用此方法来绘出子视图.可被衍生类重写,以便在其子项被画出之前取得控制权.
void)">dispatchFreezeSelfOnly(SparseArray container) Perform dispatching of a)">freeze() to only this view, not to its children.
booleandispatchKeyEvent(KeyEvent event) 按照焦点路径分发键盘事件到下一个视图.
booleandispatchKeyEventPreIme(KeyEvent event) Dispatch a key event before it is processed by any input method associated with the view hierarchy.
booleandispatchKeyShortcutEvent(KeyEvent event) Dispatches a key shortcut event.
booleandispatchPopulateAccessibilityEvent(AccessibilityEvent event) 分发AccessibilityEvent 事件到该视图 的子视图中.
void)">dispatchRestoreInstanceState(SparseArray container) Called by)">restoreHierarchyState(SparseArray) to retrieve the state for this view and its children.
void)">dispatchSaveInstanceState(SparseArray container) Called by)">saveHierarchyState(SparseArray) to store the state for this view and its children.
voiddispatchSetPressed(boolean pressed) 为视图的所有子视图调用 setPressed 方法.
voiddispatchSetSelected(boolean selected) 为视图的所有子视图调用 setSelected 方法.
void)">dispatchThawSelfOnly(SparseArray container) Perform dispatching of a)">thaw() to only this view, not to its children.
booleandispatchTouchEvent(MotionEvent ev) Pass the touch screen motion event down to the target view, or this view if it is the target.
booleandispatchTrackballEvent(MotionEvent event) Pass a trackball motion event down to the focused view.
booleandispatchUnhandledMove(View focused, int direction) 对于具有焦点的视图及其祖先,该方法是处理箭头事件最后的机会.
voiddispatchVisibilityChanged(View changedView, int visibility) Dispatch a view visibility change down the view hierarchy.
voiddispatchWindowFocusChanged(boolean hasFocus) 当包含的此视图的窗口获得或失去焦点时调用此方法.视图组应该重写此方法, 将消息传递到他的子视图.
voiddispatchWindowVisibilityChanged(int visibility) Dispatch a window visibility change down the view hierarchy.
booleandrawChild(Canvas canvas,View child, long drawingTime) Draw one child of this View Group.
voiddrawableStateChanged() 在视图状态的变化影响到所显示可绘制对象的状态时调用该方法.
ViewfindFocus() Find the view in the hierarchy rooted at this view that currently has focus.
booleanfitSystemWindows(Rect insets) Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag is set
ViewfocusSearch(View focused, int direction) Find the nearest view in the specified direction that wants to take focus.
voidfocusableViewAvailable(View v) 告诉父视图,一个新的可得焦点视图可用了。该方法用于处理, 从没有的可焦点的视图,到出现第一个可得焦点视图时的转变。
booleangatherTransparentRegion(Region region) This is used by the RootView to perform an optimization when the view hierarchy contains one or several SurfaceView.
ViewGroup.LayoutParamsgenerateDefaultLayoutParams() 返回默认布局参数集合.当使用没有设置布局参数的视图调用addView(View) 时,这些参数是必须的.如果返回空,addView 方法会抛出异常.
ViewGroup.LayoutParamsgenerateLayoutParams(AttributeSet attrs) 返回一组基于提供的属性集合的布局参数集合.
ViewGroup.LayoutParamsgenerateLayoutParams(ViewGroup.LayoutParams p) 基于提供的布局参数返回一组安全的布局参数集合.当传入 ViewGroup 的视图的参数没有通过checkLayoutParams(android.view.ViewGroup.LayoutParams) 的检测时,调用该方法.
ViewgetChildAt(int index) Returns the view at the specified position in the group.
intgetChildCount() Returns the number of children in the group.
intgetChildDrawingOrder(int childCount, int i) 返回当前迭代要绘制的子视图的索引.如果要改变绘制子视图的顺序,应该重载该方法.
static intgetChildMeasureSpec(int spec, int padding, int childDimension) Does the hard part of measureChildren: figuring out the MeasureSpec to pass to a particular child.
booleangetChildStaticTransformation(View child,Transformation t)
booleangetChildVisibleRect(View child,Rect r,Point offset)
intgetDescendantFocusability() Gets the descendant focusability of this view group.
ViewgetFocusedChild() Returns the focused child of this view, if any.
LayoutAnimationControllergetLayoutAnimation() Returns the layout animation controller used to animate the group's children.
Animation.AnimationListenergetLayoutAnimationListener() Returns the animation listener to which layout animation events are sent.
intgetPersistentDrawingCache() Returns an integer indicating what types of drawing caches are kept in memory.
booleanhasFocus() 如果该视图或其包含的视图具有焦点则返回真.
booleanhasFocusable() Returns true if this view is focusable or if it contains a reachable View for whichhasFocusable() returns true.
intindexOfChild(View child) Returns the position in the group of the specified child view.
final voidinvalidateChild(View child,Rect dirty) Don't call or override this method.
ViewParentinvalidateChildInParent(int[] location,Rect dirty) Don't call or override this method.
booleanisAlwaysDrawnWithCacheEnabled() Indicates whether this ViewGroup will always try to draw its children using their drawing cache.
booleanisAnimationCacheEnabled() Indicates whether the children's drawing cache is used during a layout animation.
booleanisChildrenDrawingOrderEnabled() Indicates whether the ViewGroup is drawing its children in the order defined bygetChildDrawingOrder(int, int).
booleanisChildrenDrawnWithCacheEnabled() Indicates whether the ViewGroup is currently drawing its children using their drawing cache.
voidmeasureChild(View child, int parentWidthMeasureSpec, int parentHeightMeasureSpec) 传入本视图必要的宽度和高度及其内边距,要求子视图调整自身设置。 主要操作都是在 getChildMeasureSpec 函数中完成的。
voidmeasureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) 传入已占用的宽度和高度、本视图必要的宽度和高度及其内边距,要求子视图调整自身设置。 主要操作都是在 getChildMeasureSpec 函数中完成的。
voidmeasureChildren(int widthMeasureSpec, int heightMeasureSpec) Ask all of the children of this view to measure themselves, taking into account both the MeasureSpec requirements for this view and its padding.
final voidoffsetDescendantRectToMyCoords(View descendant,Rect rect) Offset a rectangle that is in a descendant's coordinate space into our coordinate space.
final voidoffsetRectIntoDescendantCoords(View descendant,Rect rect) Offset a rectangle that is in our coordinate space into an ancestor's coordinate space.
voidonAnimationEnd() Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view.
voidonAnimationStart() Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view.
int[]onCreateDrawableState(int extraSpace) 为当前视图生成新的Drawable 状态时发生.
booleanonInterceptTouchEvent(MotionEvent ev) 使用此方法可以拦截所有触摸屏动作引发的事件.这意味着你可以监视分派给子项的事件, 并且可以在当前手势的任何一点获得其控制权.
abstract voidonLayout(boolean changed, int l, int t, int r, int b) 该视图设置其子视图的大小及位置时调用.派生类可以重写此方法,并为其子类布局.
booleanonRequestFocusInDescendants(int direction,Rect previouslyFocusedRect) 寻找调用requestFocus() 的子视图。当要使子视图得到焦点时,由requestFocus(int, android.graphics.Rect) 调用。 重写该方法可以定制你的视图组如何为其子视图取得焦点。
voidrecomputeViewAttributes(View child) 告诉视图层次,全局视图属性需要重新评价。
voidremoveAllViews() 调用此方法可以从视图组中移除所有视图.
voidremoveAllViewsInLayout() Called by a ViewGroup subclass to remove child views from itself, when it must first know its size on screen before it can calculate how many child views it will render.
voidremoveDetachedView(View child, boolean animate) Finishes the removal of a detached view.
voidremoveView(View view)
voidremoveViewAt(int index) 移除视图组中指定位置的视图.
voidremoveViewInLayout(View view) 在布局期间移除视图.用于在 onLayout() 方法中移除指定的视图.
voidremoveViews(int start, int count) 从视图组中移除指定索引范围的视图.
voidremoveViewsInLayout(int start, int count) 在布局期间移除指定索引范围的视图.用于在 onLayout() 方法中移除指定的视图.
voidrequestChildFocus(View child,View focused) 当父视图的子视图请求获得焦点时,调用此方法。
booleanrequestChildRectangleOnScreen(View child,Rect rectangle, boolean immediate) 当视图组里的某个子视图需要定位到屏幕上的特定矩形区域时,调用此方法.
voidrequestDisallowInterceptTouchEvent(boolean disallowIntercept) 当子视图不希望他的父类及其祖先使用onInterceptTouchEvent(MotionEvent) 打断触控事件时调用。
父视图应该调用其父类的该方法。父类必须在触控事件期间遵守该请求, 就是说,父类只有在收到抬起事件或取消事件时才可以清楚该标志。
booleanrequestFocus(int direction,Rect previouslyFocusedRect) Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from. Looks for a view to give focus to respecting the setting specified bygetDescendantFocusability().
voidrequestTransparentRegion(View child) 当子视图需要收集视图层次中透明区域并报告给窗口排版组件时调用。 需要在视图层次中“打洞”的视图,比如SurfaceView可以利用该API 来提高系统性能。当视图层次中没有这样的视图时,不需要该优化, 使用它会稍微降低一些视图层次的性能。
voidscheduleLayoutAnimation() Schedules the layout animation to be played after the next layout pass of this view group.
voidsetAddStatesFromChildren(boolean addsStates) Sets whether this ViewGroup's drawable states also include its children's drawable states.
voidsetAlwaysDrawnWithCacheEnabled(boolean always) Indicates whether this ViewGroup will always try to draw its children using their drawing cache.
voidsetAnimationCacheEnabled(boolean enabled) Enables or disables the children's drawing cache during a layout animation.
voidsetChildrenDrawingCacheEnabled(boolean enabled) Enables or disables the drawing cache for each child of this view group.
voidsetChildrenDrawingOrderEnabled(boolean enabled) Tells the ViewGroup whether to draw its children in the order defined by the methodgetChildDrawingOrder(int, int).
voidsetChildrenDrawnWithCacheEnabled(boolean enabled) Tells the ViewGroup to draw its children using their drawing cache.
voidsetClipChildren(boolean clipChildren) By default, children are clipped to their bounds before drawing.
voidsetClipToPadding(boolean clipToPadding) By default, children are clipped to the padding of the ViewGroup.
voidsetDescendantFocusability(int focusability) Set the descendant focusability of this view group.
voidsetLayoutAnimation(LayoutAnimationController controller) Sets the layout animation controller used to animate the group's children after the first layout.
voidsetLayoutAnimationListener(Animation.AnimationListener animationListener) Specifies the animation listener to which layout animation events must be sent.
voidsetOnHierarchyChangeListener(ViewGroup.OnHierarchyChangeListener listener) 注册当从视图中添加或移除子视图时发生的回调函数.
voidsetPadding(int left, int top, int right, int bottom) 设置内边距.视图可能会根据滚动条的样式和可视性,增加一些必要的用于显示滚动条的空间.
voidsetPersistentDrawingCache(int drawingCacheToKeep) Indicates what types of drawing caches should be kept in memory after they have been created.
voidsetStaticTransformationsEnabled(boolean enabled) When this property is set to true, this ViewGroup supports static transformations on children; this causesgetChildStaticTransformation(View, android.view.animation.Transformation) to be invoked when a child is drawn.
booleanshowContextMenuForChild(View originalView) 为指定的视图或者其父类显示上下文菜单.
voidstartLayoutAnimation() Runs the layout animation.
voidupdateViewLayout(View view,ViewGroup.LayoutParams params)
来自 classandroid.view.View
void, int)">addFocusables(ArrayList views, int direction) Add any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views.
void, int, int)">addFocusables(ArrayList views, int direction, int focusableMode) Adds any focusable views that are descendants of this view (possibly including this view if it is focusable itself) to views.
void)">addTouchables(ArrayList views) 想views添加可触控视图,该可触控视图是该视图的后代(如果该视图可触控, 也可以添加该视图)。
booleanawakenScrollBars(int startDelay)
Trigger the scrollbars to draw.
booleanawakenScrollBars(int startDelay, boolean invalidate)
Trigger the scrollbars to draw.
booleanawakenScrollBars()
Trigger the scrollbars to draw.
voidbringToFront() Change the view's z order in the tree, so it's on top of other sibling views
voidbuildDrawingCache(boolean autoScale)
Forces the drawing cache to be built if the drawing cache is invalid.
voidbuildDrawingCache()
Calling this method is equivalent to calling buildDrawingCache(false).
voidcancelLongPress() Cancels a pending long press.
booleancheckInputConnectionProxy(View view) Called by theInputMethodManager when a view who is not the current input connection target is trying to make a call on the manager.
voidclearAnimation() Cancels any animations for this view.
voidclearFocus() Called when this view wants to give up focus.
intcomputeHorizontalScrollExtent()
在水平范围内计算滚动条滑块的滚动范围.该值用来计算滚动条滑块的长度.
intcomputeHorizontalScrollOffset()
在水平范围内计算滚动条滑块的偏移量.该值用来计算水平滑块的位置.
intcomputeHorizontalScrollRange()
计算滚动条水平方向上的滚动范围.
voidcomputeScroll() 由父视图调用,用于通知子视图在必要时更新 mScrollX 和 mScrollY 的值。 该操作主要用于子视图使用Scroller 进行动画滚动时。
intcomputeVerticalScrollExtent()
计算滚动条把手在纵向滚动范围内占用的幅度.该值用于计算滚动条把手在滚动条滑道中的长度.
intcomputeVerticalScrollOffset()
计算滚动条把手在纵向滚动范围内的位置.该值用于计算滚动条把手在滚动条滑道中的位置.
intcomputeVerticalScrollRange()
计算滚动条代表的纵向范围.
voidcreateContextMenu(ContextMenu menu) Show the context menu for this view.
voiddestroyDrawingCache()
Frees the resources used by the drawing cache.
voiddispatchConfigurationChanged(Configuration newConfig) Dispatch a notification about a resource configuration change down the view hierarchy.
voiddispatchDisplayHint(int hint) Dispatch a hint about whether this view is displayed.
voiddispatchDraw(Canvas canvas) 调用此方法来绘出子视图.可被衍生类重写,以便在其子项被画出之前取得控制权.
booleandispatchKeyEvent(KeyEvent event) 按照焦点路径分发键盘事件到下一个视图.
booleandispatchKeyEventPreIme(KeyEvent event) Dispatch a key event before it is processed by any input method associated with the view hierarchy.
booleandispatchKeyShortcutEvent(KeyEvent event) Dispatches a key shortcut event.
booleandispatchPopulateAccessibilityEvent(AccessibilityEvent event) 分发AccessibilityEvent 事件到该视图 的子视图中.
void)">dispatchRestoreInstanceState(SparseArray container) Called by)">restoreHierarchyState(SparseArray) to retrieve the state for this view and its children.
void)">dispatchSaveInstanceState(SparseArray container) Called by)">saveHierarchyState(SparseArray) to store the state for this view and its children.
voiddispatchSetPressed(boolean pressed) 为视图的所有子视图调用 setPressed 方法.
voiddispatchSetSelected(boolean selected) 为视图的所有子视图调用 setSelected 方法.
booleandispatchTouchEvent(MotionEvent event) Pass the touch screen motion event down to the target view, or this view if it is the target.
booleandispatchTrackballEvent(MotionEvent event) Pass a trackball motion event down to the focused view.
booleandispatchUnhandledMove(View focused, int direction) 对于具有焦点的视图及其祖先,该方法是处理箭头事件最后的机会.
voiddispatchVisibilityChanged(View changedView, int visibility) Dispatch a view visibility change down the view hierarchy.
voiddispatchWindowFocusChanged(boolean hasFocus) 当包含的此视图的窗口获得或失去焦点时调用此方法.视图组应该重写此方法, 将消息传递到他的子视图.
voiddispatchWindowVisibilityChanged(int visibility) Dispatch a window visibility change down the view hierarchy.
voiddraw(Canvas canvas) 在指定的画布上手动绘制视图(及其子视图).
voiddrawableStateChanged() 在视图状态的变化影响到所显示可绘制对象的状态时调用该方法.
ViewfindFocus() Find the view in the hierarchy rooted at this view that currently has focus.
finalViewfindViewById(int id) Look for a child view with the given id.
finalViewfindViewWithTag(Object tag) Look for a child view with the given tag.
booleanfitSystemWindows(Rect insets) Apply the insets for system windows to this view, if the FITS_SYSTEM_WINDOWS flag is set
ViewfocusSearch(int direction) Find the nearest view in the specified direction that can take focus.
voidforceLayout() Forces this view to be laid out during the next layout pass.
AnimationgetAnimation() Get the animation currently associated with this view.
IBindergetApplicationWindowToken() Retrieve a unique token identifying the top-level "real" window of the window that this view is attached to.
DrawablegetBackground() Gets the background drawable
intgetBaseline()
返回小部件顶端到文本基线的偏移量.如果小部件不支持基线对齐,该方法返回 -1.
final intgetBottom() Bottom position of this view relative to its parent.
floatgetBottomFadingEdgeStrength() 返回底部渐变边缘的强度或密集度.强度的值介于0.0(无渐变)到1.0(全渐变)之间.
intgetBottomPaddingOffset() 扩展的底部渐近区域量。只有当isPaddingOffsetRequired() 返回真时会调用该函数。
CharSequencegetContentDescription() Gets theView description.
finalContextgetContext() Returns the context the view is running in, through which it can access the current theme, resources, etc.
ContextMenu.ContextMenuInfogetContextMenuInfo() 如果视图要向上下文菜单加入额外信息,就应该实现该方法.返回的结果作为onCreateContextMenu(ContextMenu, View, ContextMenuInfo) 回调函数的参数.
static intgetDefaultSize(int size, int measureSpec) Utility to return a default size.
final int[]getDrawableState() Return an array of resource IDs of the drawable states representing the current state of the view.
BitmapgetDrawingCache(boolean autoScale)
Returns the bitmap in which this view drawing is cached.
BitmapgetDrawingCache()
Calling this method is equivalent to calling getDrawingCache(false).
intgetDrawingCacheBackgroundColor()
intgetDrawingCacheQuality() Returns the quality of the drawing cache.
voidgetDrawingRect(Rect outRect) Return the visible drawing bounds of your view.
longgetDrawingTime()
Return the time at which the drawing of the view hierarchy started.
booleangetFilterTouchesWhenObscured() Gets whether the framework should discard touches when the view's window is obscured by another visible window.
ArrayListgetFocusables(int direction) Find and return all focusable views that are descendants of this view, possibly including this view if it is focusable itself.
voidgetFocusedRect(Rect r) 在视图拥有焦点时,用户将焦点移向其他视图,可以使用该方法取得下一个视图的 矩形填充区域。 默认情况,该矩形为视图的getDrawingRect(Rect)。当然,如果你的视图维护着 内部选中状态,比如游标、选中的行或列,你应该重写该方法,并返回特定的矩形。
booleangetGlobalVisibleRect(Rect r,Point globalOffset) If some part of this view is not clipped by any of its parents, then return that area in r in global (root) coordinates.
final booleangetGlobalVisibleRect(Rect r)
HandlergetHandler()
final intgetHeight() Return the height of your view.
voidgetHitRect(Rect outRect) Hit rectangle in parent's coordinates
intgetHorizontalFadingEdgeLength() Returns the size of the horizontal faded edges used to indicate that more content in this view is visible.
intgetHorizontalScrollbarHeight() Returns the height of the horizontal scrollbar.
intgetId() Returns this view's identifier.
booleangetKeepScreenOn() Returns whether the screen should remain on, corresponding to the current value ofKEEP_SCREEN_ON.
KeyEvent.DispatcherStategetKeyDispatcherState() Return the globalKeyEvent.DispatcherState for this view's window.
ViewGroup.LayoutParamsgetLayoutParams() Get the LayoutParams associated with this view.
final intgetLeft() Left position of this view relative to its parent.
floatgetLeftFadingEdgeStrength() 返回左渐变边缘的强度或密集度.强度的值介于0.0(无渐变)到1.0(全渐变)之间.
intgetLeftPaddingOffset() 扩展的左侧渐近区域量。只有当isPaddingOffsetRequired() 返回真时会调用该函数。
final booleangetLocalVisibleRect(Rect r)
voidgetLocationInWindow(int[] location)
Computes the coordinates of this view in its window.
voidgetLocationOnScreen(int[] location)
Computes the coordinates of this view on the screen.
final intgetMeasuredHeight() The height of this view as measured in the most recent call to measure().
final intgetMeasuredWidth() The width of this view as measured in the most recent call to measure().
intgetNextFocusDownId()
intgetNextFocusLeftId()
intgetNextFocusRightId()
intgetNextFocusUpId()
View.OnFocusChangeListenergetOnFocusChangeListener() Returns the focus-change callback registered for this view.
intgetOverScrollMode() Returns the over-scroll mode for this view.
intgetPaddingBottom() Returns the bottom padding of this view.
intgetPaddingLeft() Returns the left padding of this view.
intgetPaddingRight() Returns the right padding of this view.
intgetPaddingTop() Returns the top padding of this view.
finalViewParentgetParent() Gets the parent of this view.
ResourcesgetResources() Returns the resources associated with this view.
final intgetRight() Right position of this view relative to its parent.
floatgetRightFadingEdgeStrength() 返回右渐变边缘的强度或密集度.强度的值介于0.0(无渐变)到1.0(全渐变)之间.
intgetRightPaddingOffset() 扩展的右侧渐近区域量。只有当isPaddingOffsetRequired() 返回真时会调用该函数。
ViewgetRootView()
Finds the topmost view in the current view hierarchy.
intgetScrollBarStyle()
Returns the current scrollbar style.
final intgetScrollX() Return the scrolled left position of this view.
final intgetScrollY() Return the scrolled top position of this view.
intgetSolidColor() 如果你的视图总是在单色背景上绘制,并且需要渐变的边时,重载该函数。 返回非零的颜色值,使视图系统可以优化渐进边的绘制。返回非零颜色值时, 阿尔法通道应设为 0xFF。
intgetSuggestedMinimumHeight() Returns the suggested minimum height that the view should use.
intgetSuggestedMinimumWidth() Returns the suggested minimum width that the view should use.
ObjectgetTag(int key) Returns the tag associated with this view and the specified key.
ObjectgetTag() Returns this view's tag.
final intgetTop() Top position of this view relative to its parent.
floatgetTopFadingEdgeStrength() 返回顶部渐变边缘的强度或密集度.强度的值介于0.0(无渐变)到1.0(全渐变)之间.
intgetTopPaddingOffset() 扩展的顶部渐近区域量。只有当isPaddingOffsetRequired() 返回真时会调用该函数。
TouchDelegategetTouchDelegate() Gets the TouchDelegate for this View.
ArrayListgetTouchables() Find and return all touchable views that are descendants of this view, possibly including this view if it is touchable itself.
intgetVerticalFadingEdgeLength() Returns the size of the vertical faded edges used to indicate that more content in this view is visible.
intgetVerticalScrollbarWidth() Returns the width of the vertical scrollbar.
ViewTreeObservergetViewTreeObserver() 为该视图层次返回 ViewTreeObserver 对象。The view tree observer can be used to get notifications when global events, like layout, happen.
intgetVisibility() Returns the visibility status for this view.
final intgetWidth() Return the width of the your view.
intgetWindowAttachCount()
IBindergetWindowToken() Retrieve a unique token identifying the window this view is attached to.
intgetWindowVisibility() Returns the current visibility of the window this view is attached to (eitherGONE,INVISIBLE, orVISIBLE).
voidgetWindowVisibleDisplayFrame(Rect outRect) Retrieve the overall visible display size in which the window this view is attached to has been positioned in.
booleanhasFocus() Returns true if this view has focus iteself, or is the ancestor of the view that has focus.
booleanhasFocusable() Returns true if this view is focusable or if it contains a reachable View for whichhasFocusable() returns true.
booleanhasWindowFocus() Returns true if this view is in a window that currently has window focus.
staticViewinflate(Context context, int resource,ViewGroup root) Inflate a view from an XML resource.
voidinitializeFadingEdge(TypedArray a)
Initializes the fading edges from a given set of styled attributes.
voidinitializeScrollbars(TypedArray a)
Initializes the scrollbars from a given set of styled attributes.
voidinvalidate(Rect dirty) Mark the the area defined by dirty as needing to be drawn.
voidinvalidate(int l, int t, int r, int b) Mark the the area defined by the rect (l,t,r,b) as needing to be drawn.
voidinvalidate() Invalidate the whole view.
voidinvalidateDrawable(Drawable drawable) 使指定的可绘制对象失效。
booleanisClickable() Indicates whether this view reacts to click events or not.
booleanisDrawingCacheEnabled()
Indicates whether the drawing cache is enabled for this view.
booleanisDuplicateParentStateEnabled()
Indicates whether this duplicates its drawable state from its parent.
booleanisEnabled() Returns the enabled status for this view.
final booleanisFocusable() Returns whether this View is able to take focus.
final booleanisFocusableInTouchMode() When a view is focusable, it may not want to take focus when in touch mode.
booleanisFocused() Returns true if this view has focus
booleanisHapticFeedbackEnabled()
booleanisHorizontalFadingEdgeEnabled()
Indicate whether the horizontal edges are faded when the view is scrolled horizontally.
booleanisHorizontalScrollBarEnabled()
Indicate whether the horizontal scrollbar should be drawn or not.
booleanisInEditMode() Indicates whether this View is currently in edit mode.
booleanisInTouchMode() Returns whether the device is currently in touch mode.
booleanisLayoutRequested()
Indicates whether or not this view's layout will be requested during the next hierarchy layout pass.
booleanisLongClickable() Indicates whether this view reacts to long click events or not.
booleanisOpaque() Indicates whether this View is opaque.
booleanisPaddingOffsetRequired() 如果视图在内边距内绘制内容,并且启用了渐近边,他需要支持内边距位移。 内边距位移是叠加到渐近边上,扩展渐近的长度,以便包含在内边距内绘制的像素。 该类的子类如果需要在内边距中绘制内容,就应该重写该方法。
booleanisPressed() Indicates whether the view is currently in pressed state.
booleanisSaveEnabled() Indicates whether this view will save its state (that is, whether itsonSaveInstanceState() method will be called).
booleanisScrollbarFadingEnabled() Returns true if scrollbars will fade when this view is not scrolling
booleanisSelected() 指出该视图的选中状态。
booleanisShown() Returns the visibility of this view and all of its ancestors
booleanisSoundEffectsEnabled()
booleanisVerticalFadingEdgeEnabled()
Indicate whether the vertical edges are faded when the view is scrolled horizontally.
booleanisVerticalScrollBarEnabled()
Indicate whether the vertical scrollbar should be drawn or not.
final voidlayout(int l, int t, int r, int b) Assign a size and position to a view and all of its descendants
This is the second phase of the layout mechanism.
final voidmeasure(int widthMeasureSpec, int heightMeasureSpec)
This is called to find out how big a view should be.
static int[]mergeDrawableStates(int[] baseState, int[] additionalState) Merge your own state values in additionalState into the base state values baseState that were returned byonCreateDrawableState(int).
voidoffsetLeftAndRight(int offset) Offset this view's horizontal location by the specified amount of pixels.
voidoffsetTopAndBottom(int offset) Offset this view's vertical location by the specified number of pixels.
voidonAnimationEnd() Invoked by a parent ViewGroup to notify the end of the animation currently associated with this view.
voidonAnimationStart() Invoked by a parent ViewGroup to notify the start of the animation currently associated with this view.
voidonAttachedToWindow() 当视图附加到窗体上时调用该方法.在这个时点,视图拥有了用于显示的表面,将开始绘制.
booleanonCheckIsTextEditor() 检查调用的视图是否是文本编辑器,如果是可以自动为它显示软键盘窗口。 如果子类应该重写该方法, Subclasses should override this if they implementonCreateInputConnection(EditorInfo) to return true if a call on that method would return a non-null InputConnection, and they are really a first-class editor that the user would normally start typing on when the go into a window containing your view.
voidonConfigurationChanged(Configuration newConfig) Called when the current configuration of the resources being used by the application have changed.
voidonCreateContextMenu(ContextMenu menu) Views should implement this if the view itself is going to add items to the context menu.
int[]onCreateDrawableState(int extraSpace) 为当前视图生成新的Drawable 状态时发生.
InputConnectiononCreateInputConnection(EditorInfo outAttrs) 为 InputMethod 创建一个新的用于与视图交互的 InputConnection。默认实现返回null 因为他不支持输入法。你能够重写该函数来支持输入法功能。只有在视图需要得到焦点, 并允许输入文本时才有用。
如果实现了该方法,你还应该实现onCheckIsTextEditor(), 用于返回一个非空的 InputConnection。
voidonDetachedFromWindow() 将视图从屏幕上分离的时候调用该方法.这个时点视图已经不具有可绘制部分.
voidonDisplayHint(int hint) 得到视图是否处于显示状态的提示信息。例如,当视图移出屏幕时,他收到视图没有显示的提示 信息。应用程序不应该依靠该回调函数,不保证一定会收到该提示。
voidonDraw(Canvas canvas) 实现该方法,用于自己绘制内容.
final voidonDrawScrollBars(Canvas canvas)
Request the drawing of the horizontal and the vertical scrollbar.
booleanonFilterTouchEventForSecurity(MotionEvent event) Filter the touch event to apply security policies.
voidonFinishInflate() 根据 XML 生成视图工作完成.该函数在生成视图的最后调用,在所有子视图添加完之后.
voidonFinishTemporaryDetach() Called afteronStartTemporaryDetach() when the container is done changing the view.
voidonFocusChanged(boolean gainFocus, int direction,Rect previouslyFocusedRect) 当视图的焦点改变时调用.由定向导航导致的焦点变更时, direction 和 previouslyFocusedRect 提供了焦点是从那里来的进一步信息.
booleanonKeyDown(int keyCode,KeyEvent event)KeyEvent.Callback.onKeyMultiple() 的默认实现.
booleanonKeyLongPress(int keyCode,KeyEvent event) Default implementation ofKeyEvent.Callback.onKeyLongPress(): always returns false (doesn't handle the event).
booleanonKeyMultiple(int keyCode, int repeatCount,KeyEvent event)KeyEvent.Callback.onKeyMultiple() 的默认实现.
booleanonKeyPreIme(int keyCode,KeyEvent event) Handle a key event before it is processed by any input method associated with the view hierarchy.
booleanonKeyShortcut(int keyCode,KeyEvent event) Called when an unhandled key shortcut event occurs.
booleanonKeyUp(int keyCode,KeyEvent event)KeyEvent.Callback.onKeyMultiple() 的默认实现.
voidonLayout(boolean changed, int left, int top, int right, int bottom) 该视图设置其子视图的大小及位置时调用.派生类可以重写此方法,并为其子类布局.
voidonMeasure(int widthMeasureSpec, int heightMeasureSpec)
评估视图及其内容,以决定其宽度和高度.此方法由measure(int, int) 调用,子类可以重载以提供更精确、更有效率的衡量其内容尺寸的方法.
voidonOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) 由overScrollBy(int, int, int, int, int, int, int, int, boolean) 调用,用于响应过滚动操作.
voidonRestoreInstanceState(Parcelable state) 允许视图重新应用之前由onSaveInstanceState() 保存的内部状态的回调函数.
ParcelableonSaveInstanceState() 允许视图保存其内部状态的回调函数,以便于之后使用相同状态创建新实例.
voidonScrollChanged(int l, int t, int oldl, int oldt) This is called in response to an internal scroll in this view (i.e., the view scrolled its own contents).
booleanonSetAlpha(int alpha) 执行阿尔法变换时执行.子类可以使用该方法指定阿尔法值,然后返回真; 在调用 onDraw() 时,使用该阿尔法值.如果返回假,则先在不可见的缓存中绘制视图, 完成该请求;看起来不错,但是可能相对于在子类中绘制要慢.默认实现返回假.
voidonSizeChanged(int w, int h, int oldw, int oldh) 布局时该视图的大小发生改变时调用该方法.如果是刚加入的视图,变更前的值为 0.
voidonStartTemporaryDetach() This is called when a container is going to temporarily detach a child, withViewGroup.detachViewFromParent.
booleanonTouchEvent(MotionEvent event) 实现该方法来处理触屏事件.
booleanonTrackballEvent(MotionEvent event) 实现该方法来处理轨迹球动作事件。轨迹球相对于上次移动的位置可以通过MotionEvent.getX() 和MotionEvent.getY() 取得。对应用户按下一次方向键, 他们通常作为一次移动处理(为了表现来自轨迹球的更小粒度的移动信息,他们返回小数)。
voidonVisibilityChanged(View changedView, int visibility) Called when the visibility of the view or an ancestor of the view is changed.
voidonWindowFocusChanged(boolean hasWindowFocus) 包含该视图的窗体获得或失去焦点时调用该函数。注意,该动作是与视图的焦点 分开的:为了受到键盘事件,你的视图及其窗口都必须拥有焦点。如果有窗口 覆盖在你的窗口上方并得到输入焦点,你的窗口会失去焦点,但是视图的焦点 保持不变。
voidonWindowVisibilityChanged(int visibility) 当窗口中内容的可视性在GONE 、INVISIBLE 和VISIBLE 之间变更时调用.注意,该可视性代表你的窗口在窗口管理器中是否可见;并不 会告诉你属性为VISIBLE 的窗口在屏幕上是否可见.
booleanoverScrollBy(int deltaX, int deltaY, int scrollX, int scrollY, int scrollRangeX, int scrollRangeY, int maxOverScrollX, int maxOverScrollY, boolean isTouchEvent) Scroll the view with standard behavior for scrolling beyond the normal content boundaries.
booleanperformClick() 如果该视图定义了 OnClickListener,则调用它.
booleanperformHapticFeedback(int feedbackConstant, int flags) BZZZTT!!1!
LikeperformHapticFeedback(int), with additional options.
booleanperformHapticFeedback(int feedbackConstant) BZZZTT!!1!
Provide haptic feedback to the user for this view.
booleanperformLongClick() Call this view's OnLongClickListener, if it is defined.
voidplaySoundEffect(int soundConstant) Play a sound effect for this view.
booleanpost(Runnable action) Causes the Runnable to be added to the message queue.
booleanpostDelayed(Runnable action, long delayMillis) Causes the Runnable to be added to the message queue, to be run after the specified amount of time elapses.
voidpostInvalidate(int left, int top, int right, int bottom) Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop.
voidpostInvalidate() Cause an invalidate to happen on a subsequent cycle through the event loop.
voidpostInvalidateDelayed(long delayMilliseconds, int left, int top, int right, int bottom) Cause an invalidate of the specified area to happen on a subsequent cycle through the event loop.
voidpostInvalidateDelayed(long delayMilliseconds) Cause an invalidate to happen on a subsequent cycle through the event loop.
voidrefreshDrawableState() Call this to force a view to update its drawable state.
booleanremoveCallbacks(Runnable action) Removes the specified Runnable from the message queue.
booleanrequestFocus(int direction,Rect previouslyFocusedRect) Call this to try to give focus to a specific view or to one of its descendants and give it hints about the direction and a specific rectangle that the focus is coming from.
final booleanrequestFocus(int direction) Call this to try to give focus to a specific view or to one of its descendants and give it a hint about what direction focus is heading.
final booleanrequestFocus() Call this to try to give focus to a specific view or to one of its descendants.
final booleanrequestFocusFromTouch() Call this to try to give focus to a specific view or to one of its descendants.
voidrequestLayout() 当某些变更导致视图的布局失效时调用该方法.该方法按照视图树的顺序调用.
booleanrequestRectangleOnScreen(Rect rectangle) Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough.
booleanrequestRectangleOnScreen(Rect rectangle, boolean immediate) Request that a rectangle of this view be visible on the screen, scrolling if necessary just enough.
static intresolveSize(int size, int measureSpec) Utility to reconcile a desired size with constraints imposed by a MeasureSpec.
void)">restoreHierarchyState(SparseArray container) Restore this view hierarchy's frozen state from the given container.
void)">saveHierarchyState(SparseArray container) Store this view hierarchy's frozen state into the given container.
voidscheduleDrawable(Drawable who,Runnable what, long when) Schedules an action on a drawable to occur at a specified time.
voidscrollBy(int x, int y) Move the scrolled position of your view.
voidscrollTo(int x, int y) 设置视图的滚动位置。会触发onScrollChanged(int, int, int, int) 事件,并使视图失效重绘。
voidsendAccessibilityEvent(int eventType) Handles the request for sending anAccessibilityEvent given the event type.
voidsendAccessibilityEventUnchecked(AccessibilityEvent event) Handles the request for sending anAccessibilityEvent.
voidsetAnimation(Animation animation) Sets the next animation to play for this view.
voidsetBackgroundColor(int color) Sets the background color for this view.
voidsetBackgroundDrawable(Drawable d) 将指定的可绘制对象设为背景;或删除背景.如果指定的可绘制对象有内边距, 则这个视图的内边距就会设为可绘制对象的内边距.然而,当背景被移除时,视图的内边距不变.
voidsetBackgroundResource(int resid) Set the background to a given resource.
voidsetClickable(boolean clickable) Enables or disables click events for this view.
voidsetContentDescription(CharSequence contentDescription) Sets theView description.
voidsetDrawingCacheBackgroundColor(int color) Setting a solid background color for the drawing cache's bitmaps will improve perfromance and memory usage.
voidsetDrawingCacheEnabled(boolean enabled)
Enables or disables the drawing cache.
voidsetDrawingCacheQuality(int quality) Set the drawing cache quality of this view.
voidsetDuplicateParentStateEnabled(boolean enabled)
Enables or disables the duplication of the parent's state into this view.
voidsetEnabled(boolean enabled) 设置视图的可用状态.由子类决定视图的各可用状态如何显示.
voidsetFadingEdgeLength(int length) Set the size of the faded edge used to indicate that more content in this view is available.
voidsetFilterTouchesWhenObscured(boolean enabled) Sets whether the framework should discard touches when the view's window is obscured by another visible window.
voidsetFocusable(boolean focusable) 设置该视图是否可以获取焦点.
voidsetFocusableInTouchMode(boolean focusableInTouchMode) 设置在触控模式下该视图是否可以获取焦点.
voidsetHapticFeedbackEnabled(boolean hapticFeedbackEnabled) Set whether this view should have haptic feedback for events such as long presses.
voidsetHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)
Define whether the horizontal edges should be faded when this view is scrolled horizontally.
voidsetHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)
Define whether the horizontal scrollbar should be drawn or not.
voidsetId(int id) Sets the identifier for this view.
voidsetKeepScreenOn(boolean keepScreenOn) Controls whether the screen should remain on, modifying the value ofKEEP_SCREEN_ON.
voidsetLayoutParams(ViewGroup.LayoutParams params) Set the layout parameters associated with this view.
voidsetLongClickable(boolean longClickable) Enables or disables long click events for this view.
final voidsetMeasuredDimension(int measuredWidth, int measuredHeight)
This mehod must be called byonMeasure(int, int) to store the measured width and measured height.
voidsetMinimumHeight(int minHeight) Sets the minimum height of the view.
voidsetMinimumWidth(int minWidth) Sets the minimum width of the view.
voidsetNextFocusDownId(int nextFocusDownId) Set the id of the view to use for the next focus
voidsetNextFocusLeftId(int nextFocusLeftId) Set the id of the view to use for the next focus
voidsetNextFocusRightId(int nextFocusRightId) Set the id of the view to use for the next focus
voidsetNextFocusUpId(int nextFocusUpId) Set the id of the view to use for the next focus
voidsetOnClickListener(View.OnClickListener l) 注册点击该视图时执行的回调函数.如果该视图不可点击,会将其改为可以点击的状态.
voidsetOnCreateContextMenuListener(View.OnCreateContextMenuListener l) Register a callback to be invoked when the context menu for this view is being built.
voidsetOnFocusChangeListener(View.OnFocusChangeListener l) Register a callback to be invoked when focus of this view changed.
voidsetOnKeyListener(View.OnKeyListener l) Register a callback to be invoked when a key is pressed in this view.
voidsetOnLongClickListener(View.OnLongClickListener l) Register a callback to be invoked when this view is clicked and held.
voidsetOnTouchListener(View.OnTouchListener l) Register a callback to be invoked when a touch event is sent to this view.
voidsetOverScrollMode(int overScrollMode) 为视图设置过滚动模式。有效的过滚动模式有OVER_SCROLL_ALWAYS(默认值)、OVER_SCROLL_IF_CONTENT_SCROLLS(视图内容大于容器时允许过滚动)、 和OVER_SCROLL_NEVER.
voidsetPadding(int left, int top, int right, int bottom) 设置内边距.视图可能会根据滚动条的样式和可视性,增加一些必要的用于显示滚动条的空间.
voidsetPressed(boolean pressed) Sets the pressed that for this view.
voidsetSaveEnabled(boolean enabled) Controls whether the saving of this view's state is enabled (that is, whether itsonSaveInstanceState() method will be called).
voidsetScrollBarStyle(int style)
Specify the style of the scrollbars.
voidsetScrollContainer(boolean isScrollContainer) Change whether this view is one of the set of scrollable containers in its window.
voidsetScrollbarFadingEnabled(boolean fadeScrollbars) Define whether scrollbars will fade when the view is not scrolling.
voidsetSelected(boolean selected) 改变视图的选中状态。视图有选中和未选中两个状态。注意,选择状态不同于焦点。 典型的选中的视图是象 ListView 和 GridView 这样的 AdapterView 中显示的 内容;选中的内容会显示为高亮。
voidsetSoundEffectsEnabled(boolean soundEffectsEnabled) Set whether this view should have sound effects enabled for events such as clicking and touching.
voidsetTag(int key,Object tag) Sets a tag associated with this view and a key.
voidsetTag(Object tag) Sets the tag associated with this view.
voidsetTouchDelegate(TouchDelegate delegate) Sets the TouchDelegate for this View.
voidsetVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled)
Define whether the vertical edges should be faded when this view is scrolled vertically.
voidsetVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)
Define whether the vertical scrollbar should be drawn or not.
voidsetVisibility(int visibility) Set the enabled state of this view.
voidsetWillNotCacheDrawing(boolean willNotCacheDrawing) When a View's drawing cache is enabled, drawing is redirected to an offscreen bitmap.
voidsetWillNotDraw(boolean willNotDraw) If this view doesn't do any drawing on its own, set this flag to allow further optimizations.
booleanshowContextMenu() 显示该视图上下文菜单.
voidstartAnimation(Animation animation) Start the specified animation now.
voidunscheduleDrawable(Drawable who) Unschedule any events associated with the given Drawable.
voidunscheduleDrawable(Drawable who,Runnable what) Cancels a scheduled action on a drawable.
booleanverifyDrawable(Drawable who) 如果你的视图子类显示自己的可绘制对象,他应该重写此方法并为自己的每个可绘制对象返回真.
booleanwillNotCacheDrawing() Returns whether or not this View can cache its drawing or not.
booleanwillNotDraw() Returns whether or not this View draws on its own.
来自 classjava.lang.Object
Objectclone() Creates and returns a copy of this Object.
booleanequals(Object o) Compares this instance with the specified object and indicates if they are equal.
voidfinalize() Called before the object's memory is reclaimed by the VM.
finalClassgetClass() Returns the unique instance ofClass that represents this object's class.
inthashCode() Returns an integer hash code for this object.
final voidnotify() Causes a thread which is waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.
final voidnotifyAll() Causes all threads which are waiting on this object's monitor (by means of calling one of the wait() methods) to be woken up.
StringtoString() 返回一个简明但易于读懂的该对象的描述.
final voidwait() Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
final voidwait(long millis, int nanos) Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.
final voidwait(long millis) Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the specified timeout expires.
来自 interfaceandroid.graphics.drawable.Drawable.Callback
abstract voidinvalidateDrawable(Drawable who) Called when the drawable needs to be redrawn.
abstract voidscheduleDrawable(Drawable who,Runnable what, long when) A Drawable can call this to schedule the next frame of its animation.
abstract voidunscheduleDrawable(Drawable who,Runnable what) A Drawable can call this to unschedule an action previously scheduled withscheduleDrawable(Drawable, Runnable, long).
来自 interfaceandroid.view.KeyEvent.Callback
abstract booleanonKeyDown(int keyCode,KeyEvent event) Called when a key down event has occurred.
abstract booleanonKeyLongPress(int keyCode,KeyEvent event) Called when a long press has occurred.
abstract booleanonKeyMultiple(int keyCode, int count,KeyEvent event) Called when multiple down/up pairs of the same key have occurred in a row.
abstract booleanonKeyUp(int keyCode,KeyEvent event) Called when a key up event has occurred.
来自 interfaceandroid.view.ViewManager
abstract voidaddView(View view,ViewGroup.LayoutParams params)
abstract voidremoveView(View view)
abstract voidupdateViewLayout(View view,ViewGroup.LayoutParams params)
来自 interfaceandroid.view.ViewParent
abstract voidbringChildToFront(View child) 改变子视图的前后顺序,将其移动到所有视图的最前面。
abstract voidchildDrawableStateChanged(View child) 当子视图的可绘制对象状态发生改变时调用该方法。
abstract voidclearChildFocus(View child) 当该视图的子视图需要放弃焦点时调用。
abstract voidcreateContextMenu(ContextMenu menu) 通知父类,如果有必要可以向指定的上下文菜单中添加菜单项 (递归通知其父类)。
abstractViewfocusSearch(View v, int direction) 在指定的方向找到最近的可以获得焦点的视图。
abstract voidfocusableViewAvailable(View v) 告诉父视图,一个新的可得焦点视图可用了。该方法用于处理, 从没有的可焦点的视图,到出现第一个可得焦点视图时的转变。
abstract booleangetChildVisibleRect(View child,Rect r,Point offset)
abstractViewParentgetParent() 如果存在父视图,返回真,否则返回假。
abstract voidinvalidateChild(View child,Rect r) 需要重绘子视图的部分或全部区域。
abstractViewParentinvalidateChildInParent(int[] location,Rect r) 需要重绘子视图的部分或全部区域。 位置数组中分别保存了待绘制子视图的左上位置的整型数组。 如果指定的区域的父视图被设为无效,则返回父视图;如果指定矩形不会导致父视图无效, 或者不存在父视图,该方法返回空。 当返回非空值时,必须将位置数组中的值更新为本ViewParent的左上坐标。
abstract booleanisLayoutRequested() 指出该父视图是否请求了布局操作。
abstract voidrecomputeViewAttributes(View child) 告诉视图层次,全局视图属性需要重新评价。
abstract voidrequestChildFocus(View child,View focused) 当父视图的子视图请求获得焦点时,调用此方法。
abstract booleanrequestChildRectangleOnScreen(View child,Rect rectangle, boolean immediate) 当视图组里的某个子视图需要定位到屏幕上的特定矩形区域时,调用此方法.
abstract voidrequestDisallowInterceptTouchEvent(boolean disallowIntercept) 当子视图不希望他的父类及其祖先使用onInterceptTouchEvent(MotionEvent) 打断触控事件时调用。
父视图应该调用其父类的该方法。父类必须在触控事件期间遵守该请求, 就是说,父类只有在收到抬起事件或取消事件时才可以清楚该标志。
abstract voidrequestLayout() 当某些变更导致该父视图的子视图的布局失效时调用该方法.该方法按照视图树的顺序调用.
abstract voidrequestTransparentRegion(View child) 当子视图需要收集视图层次中透明区域并报告给窗口排版组件时调用。 需要在视图层次中“打洞”的视图,比如SurfaceView可以利用该API 来提高系统性能。当视图层次中没有这样的视图时,不需要该优化, 使用它会稍微降低一些视图层次的性能。
abstract booleanshowContextMenuForChild(View originalView) 为指定的视图或者其父类显示上下文菜单.
来自 interfaceandroid.view.accessibility.AccessibilityEventSource
abstract voidsendAccessibilityEvent(int eventType) Handles the request for sending anAccessibilityEvent given the event type.
abstract voidsendAccessibilityEventUnchecked(AccessibilityEvent event) Handles the request for sending anAccessibilityEvent.
XML 属性
android:baselineAligned
引入自:API 级别
When set to false, prevents the layout from aligning its children's baselines. This attribute is particularly useful when the children use different values for gravity. The default value is true.
一定是布尔值,“true”或“false”。
也可以是对包含该类型值的资源(形式为 “@[package:]type:name”)或主题属性(形式为 “[package:][type:]name”) 的参照。
相当于全局属性 资源符号baselineAligned.
相关方法
setBaselineAligned(boolean)
android:baselineAlignedChildIndex
引入自:API 级别
When a linear layout is part of another layout that is baseline aligned, it can specify which of its children to baseline align to (that is, which child TextView).
一定是整数值,比如“100”。
也可以是对包含该类型值的资源(形式为 “@[package:]type:name”)或主题属性(形式为 “[package:][type:]name”) 的参照。
相当于全局属性 资源符号baselineAlignedChildIndex.
相关方法
setBaselineAlignedChildIndex(int)
android:gravity
引入自:API 级别
指定在对象内部,横纵方向上如何放置对象的内容.
一定是下列常量中的一个或多个(由'|'分割).
常量值描述
top0x30将对象放在其容器的顶部,不改变其大小.
bottom0x50将对象放在其容器的底部,不改变其大小.
left0x03将对象放在其容器的左侧,不改变其大小.
right0x05将对象放在其容器的右侧,不改变其大小.
center_vertical0x10将对象纵向居中,不改变其大小.
fill_vertical0x70必要的时候增加对象的纵向大小,以完全充满其容器.
center_horizontal0x01将对象横向居中,不改变其大小.
fill_horizontal0x07必要的时候增加对象的横向大小,以完全充满其容器.
center0x11将对象横纵居中,不改变其大小.
fill0x77必要的时候增加对象的横纵向大小,以完全充满其容器.
clip_vertical0x80附加选项,用于按照容器的边来剪切对象的顶部和/或底部的内容. 剪切基于其纵向对齐设置:顶部对齐时,剪切底部;底部对齐时剪切顶部;除此之外剪切顶部和底部.
clip_horizontal0x08附加选项,用于按照容器的边来剪切对象的左侧和/或右侧的内容. 剪切基于其横向对齐设置:左侧对齐时,剪切右侧;右侧对齐时剪切左侧;除此之外剪切左侧和右侧.
相当于全局属性 资源符号gravity.
相关方法
setGravity(int)
android:orientation
引入自:API 级别
Should the layout be a column or a row? Use "horizontal" for a row, "vertical" for a column. The default is horizontal.
一定是下列常量之一.
常量值描述
horizontal0Defines an horizontal widget.
vertical1Defines a vertical widget.
相当于全局属性 资源符号orientation.
相关方法
setOrientation(int)
常量
public static final int HORIZONTAL
引入自:API 级别1
常量值: 0 (0x00000000)
public static final int VERTICAL
引入自:API 级别1
常量值: 1 (0x00000001)
公有构造函数
public LinearLayout (Context context)
引入自:API 级别1
public LinearLayout (Context context,AttributeSet attrs)
引入自:API 级别1
公有方法
publicLinearLayout.LayoutParams generateLayoutParams (AttributeSet attrs)
引入自:API 级别1
返回一组基于提供的属性集合的布局参数集合.
参数
attrs 用于生成布局参数的属性集.
返回值
ViewGroup.LayoutParams 或其子类的实例.
public int getBaseline ()
引入自:API 级别1
返回小部件顶端到文本基线的偏移量.如果小部件不支持基线对齐,该方法返回 -1.
返回值
小部件顶端到文本基线的偏移量;或者是 -1 当小部件不支持基线对齐时.
public int getBaselineAlignedChildIndex ()
引入自:API 级别1
返回值
The index of the child that will be used if this layout is part of a larger layout that is baseline aligned, or -1 if none has been set.
public int getOrientation ()
引入自:API 级别1
Returns the current orientation.
返回值
eitherHORIZONTAL orVERTICAL
public float getWeightSum ()
引入自:API 级别1
Returns the desired weights sum.
返回值
A number greater than 0.0f if the weight sum is defined, or a number lower than or equals to 0.0f if not weight sum is to be used.
public boolean isBaselineAligned ()
引入自:API 级别1
Indicates whether widgets contained within this layout are aligned on their baseline or not.
返回值
true when widgets are baseline-aligned, false otherwise
public void setBaselineAligned (boolean baselineAligned)
引入自:API 级别1
Defines whether widgets contained in this layout are baseline-aligned or not.
相关 XML 属性
android:baselineAligned
参数
baselineAligned true to align widgets on their baseline, false otherwise
public void setBaselineAlignedChildIndex (int i)
引入自:API 级别1
相关 XML 属性
android:baselineAlignedChildIndex
参数
i The index of the child that will be used if this layout is part of a larger layout that is baseline aligned.
public void setGravity (int gravity)
引入自:API 级别1
Describes how the child views are positioned. Defaults to GRAVITY_TOP. If this layout has a VERTICAL orientation, this controls where all the child views are placed if there is extra vertical space. If this layout has a HORIZONTAL orientation, this controls the alignment of the children.
相关 XML 属性
android:gravity
参数
gravity SeeGravity
public void setHorizontalGravity (int horizontalGravity)
引入自:API 级别1
public void setOrientation (int orientation)
引入自:API 级别1
Should the layout be a column or a row.
相关 XML 属性
android:orientation
参数
orientation Pass HORIZONTAL or VERTICAL. Default value is HORIZONTAL.
public void setVerticalGravity (int verticalGravity)
引入自:API 级别1
public void setWeightSum (float weightSum)
引入自:API 级别1
Defines the desired weights sum. If unspecified the weights sum is computed at layout time by adding the layout_weight of each child. This can be used for instance to give a single child 50% of the total available space by giving it a layout_weight of 0.5 and setting the weightSum to 1.0.
参数
weightSum a number greater than 0.0f, or a number lower than or equals to 0.0f if the weight sum should be computed from the children's layout_weight
保护方法
protected boolean checkLayoutParams (ViewGroup.LayoutParams p)
引入自:API 级别1
protectedLinearLayout.LayoutParams generateDefaultLayoutParams ()
引入自:API 级别1
返回一组包含宽度和高度的布局参数的集合.当视图为纵向布局 (VERTICAL) 时,返回的宽度为MATCH_PARENT、 高度为WRAP_CONTENT. 当视图为横向布局(HORIZONTAL)时,宽度为WRAP_CONTENT、 高度为WRAP_CONTENT.
返回值
默认布局参数集合或空.
protectedLinearLayout.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)
引入自:API 级别1
基于提供的布局参数返回一组安全的布局参数集合.当传入 ViewGroup 的视图的参数没有通过checkLayoutParams(android.view.ViewGroup.LayoutParams) 的检测时,调用该方法. 该方法会返回适合 ViewGroup 的新的布局参数,可能从指定的布局参数中复制适当的属性.
参数
p 要转换为适合于 ViewGroup 的布局参数的集合.
返回值
ViewGroup.LayoutParams 或其子类的实例.
protected void onLayout (boolean changed, int l, int t, int r, int b)
引入自:API 级别1
该视图设置其子视图的大小及位置时调用.派生类可以重写此方法,并为其子类布局.
参数
changed 是否为视图设置了新的大小和位置.
l 相对于父视图的左侧的位置.
t 相对于父视图的顶部的位置.
r 相对于父视图的右侧的位置.
b 相对于父视图的底部的位置.
protected void onMeasure (int widthMeasureSpec, int heightMeasureSpec)
引入自:API 级别1
评估视图及其内容,以决定其宽度和高度.此方法由measure(int, int) 调用,子类可以重载以提供更精确、更有效率的衡量其内容尺寸的方法.
约定: 覆盖该方法时,必须调用setMeasuredDimension(int, int) 方法来保存评估结果的视图的宽度和高度.如果忘记将导致measure(int, int) 方法抛出IllegalStateException异常.要有效的利用父类的onMeasure(int, int)方法.
基类测量的是背景的大小,除非 MeasureSpec 允许超过背景.子类应该重写onMeasure(int, int) 方法,以为其内容提供更适合的大小.
如果重写了该方法,子类要确保其高度和宽度大于等于视图的最小高度和宽度. (getSuggestedMinimumHeight() 和getSuggestedMinimumWidth())
参数
widthMeasureSpec 父视图要求的横向空间大小.该要求由View.MeasureSpec 进行了编码处理.
heightMeasureSpec 父视图要求的纵向空间大小.该要求由View.MeasureSpec 进行了编码处理.