Most visited

Recently visited

Added in API level 14

Space

public final class Space
extends View

java.lang.Object
   ↳ android.view.View
     ↳ android.widget.Space


空间是一个轻量级的View子类,可用于在通用布局中的组件之间创建间隙。

Summary

Inherited XML attributes

From class android.view.View

Inherited constants

From class android.view.View

Inherited fields

From class android.view.View

Public constructors

Space(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Space(Context context, AttributeSet attrs, int defStyleAttr)

Space(Context context, AttributeSet attrs)

Space(Context context)

Public methods

void draw(Canvas canvas)

什么都不画。

Protected methods

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

测量视图及其内容以确定测量宽度和测量高度。

Inherited methods

From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

Space

Added in API level 21
Space (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Space

Added in API level 14
Space (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context
attrs AttributeSet
defStyleAttr int

Space

Added in API level 14
Space (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

Space

Added in API level 14
Space (Context context)

Parameters
context Context

Public methods

draw

Added in API level 14
void draw (Canvas canvas)

什么都不画。

Parameters
canvas Canvas: an unused parameter.

Protected methods

onMeasure

Added in API level 14
void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

测量视图及其内容以确定测量宽度和测量高度。 此方法由measure(int, int)调用, measure(int, int)子类覆盖以提供其内容的准确和有效的度量。

合同:覆盖此方法时,您必须致电setMeasuredDimension(int, int)来存储此视图的测量宽度和高度。 如果不这样做,将触发IllegalStateException ,由measure(int, int)引发。 调用超类' onMeasure(int, int)是一个有效的用法。

Measure的基类实现默认为背景大小,除非MeasureSpec允许更大的大小。 子类应覆盖onMeasure(int, int)以提供更好的内容度量。

如果此方法被覆盖,则子类的责任是确保测量的高度和宽度至少为视图的最小高度和宽度( getSuggestedMinimumHeight()getSuggestedMinimumWidth() )。

Parameters
widthMeasureSpec int: horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec int: vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

Hooray!