Most visited

Recently visited

Added in API level 11

StackView

public class StackView
extends AdapterViewAnimator

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.AdapterView<android.widget.Adapter>
         ↳ android.widget.AdapterViewAnimator
           ↳ android.widget.StackView


Summary

Inherited XML attributes

From class android.widget.AdapterViewAnimator
From class android.view.ViewGroup
From class android.view.View

Inherited constants

From class android.widget.AdapterView
From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

StackView(Context context)

StackView(Context context, AttributeSet attrs)

StackView(Context context, AttributeSet attrs, int defStyleAttr)

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

Public methods

void advance()

AppWidgetHost调用,以便在应用程序窗口小部件中使用当前视图。

CharSequence getAccessibilityClassName()

返回此对象的类名称以用于辅助功能。

boolean onGenericMotionEvent(MotionEvent event)

实现此方法来处理通用运动事件。

boolean onInterceptTouchEvent(MotionEvent ev)

实施此方法来拦截所有触摸屏幕动作事件。

boolean onTouchEvent(MotionEvent ev)

实现此方法来处理触摸屏幕动作事件。

void showNext()

手动显示下一个孩子。

void showPrevious()

手动显示前一个孩子。

Protected methods

void dispatchDraw(Canvas canvas)

通过绘制来绘制子视图。

void onLayout(boolean changed, int left, int top, int right, int bottom)

当这个视图为每个孩子分配一个大小和位置时,从布局调用。

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

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

Inherited methods

From class android.widget.AdapterViewAnimator
From class android.widget.AdapterView
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.widget.Advanceable
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

StackView

Added in API level 11
StackView (Context context)

Parameters
context Context

StackView

Added in API level 11
StackView (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

StackView

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

Parameters
context Context
attrs AttributeSet
defStyleAttr int

StackView

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

Parameters
context Context
attrs AttributeSet
defStyleAttr int
defStyleRes int

Public methods

advance

Added in API level 11
void advance ()

AppWidgetHost调用,以便在应用程序窗口小部件中使用当前视图。

getAccessibilityClassName

Added in API level 23
CharSequence getAccessibilityClassName ()

返回此对象的类名称以用于辅助功能。 如果子类正在实现的东西应该被视为一个全新的视图类,当它被可访问性使用时,子类只应该覆盖这个子类,与它所源自的类无关。 这用于填写AccessibilityNodeInfo.setClassName

Returns
CharSequence

onGenericMotionEvent

Added in API level 12
boolean onGenericMotionEvent (MotionEvent event)

实现此方法来处理通用运动事件。

通用运动事件描述操纵杆运动,鼠标悬停,触控板触摸,滚轮运动和其他输入事件。 运动事件的source指定接收的输入类别。 此方法的实现必须在处理事件之前检查源中的位。 以下代码示例显示了这是如何完成的。

带有源类SOURCE_CLASS_POINTER通用运动事件被传递到指针下的视图。 所有其他通用运动事件都会传送到重点视图。

 public boolean onGenericMotionEvent(MotionEvent event) {
     if (event.isFromSource(InputDevice.SOURCE_CLASS_JOYSTICK)) {
         if (event.getAction() == MotionEvent.ACTION_MOVE) {
             // process the joystick movement...
             return true;
         }
     }
     if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) {
         switch (event.getAction()) {
             case MotionEvent.ACTION_HOVER_MOVE:
                 // process the mouse hover movement...
                 return true;
             case MotionEvent.ACTION_SCROLL:
                 // process the scroll wheel movement...
                 return true;
         }
     }
     return super.onGenericMotionEvent(event);
 }

Parameters
event MotionEvent: The generic motion event being processed.
Returns
boolean True if the event was handled, false otherwise.

onInterceptTouchEvent

Added in API level 11
boolean onInterceptTouchEvent (MotionEvent ev)

实施此方法来拦截所有触摸屏幕动作事件。 这允许您在事件发送给您的孩子时观看事件,并在任何时候掌握当前手势的所有权。

使用这个函数需要注意,因为它与View.onTouchEvent(MotionEvent)有相当复杂的交互,并且使用它需要以正确的方式执行该方法。 活动将按以下顺序收到:

  1. You will receive the down event here.
  2. The down event will be handled either by a child of this view group, or given to your own onTouchEvent() method to handle; this means you should implement onTouchEvent() to return true, so you will continue to see the rest of the gesture (instead of looking for a parent view to handle it). Also, by returning true from onTouchEvent(), you will not receive any following events in onInterceptTouchEvent() and all touch processing must happen in onTouchEvent() like normal.
  3. For as long as you return false from this function, each following event (up to and including the final up) will be delivered first here and then to the target's onTouchEvent().
  4. If you return true from here, you will not receive any following events: the target view will receive the same event but with the action ACTION_CANCEL, and all further events will be delivered to your onTouchEvent() method and no longer appear here.

Parameters
ev MotionEvent: The motion event being dispatched down the hierarchy.
Returns
boolean Return true to steal motion events from the children and have them dispatched to this ViewGroup through onTouchEvent(). The current target will receive an ACTION_CANCEL event, and no further messages will be delivered here.

onTouchEvent

Added in API level 11
boolean onTouchEvent (MotionEvent ev)

实现此方法来处理触摸屏幕动作事件。

如果此方法用于检测点击操作,建议通过执行并调用performClick()来执行操作。 这将确保一致的系统行为,包括:

  • obeying click sound preferences
  • dispatching OnClickListener calls
  • handling ACTION_CLICK when accessibility features are enabled

Parameters
ev MotionEvent: The motion event.
Returns
boolean True if the event was handled, false otherwise.

showNext

Added in API level 11
void showNext ()

手动显示下一个孩子。

showPrevious

Added in API level 11
void showPrevious ()

手动显示前一个孩子。

Protected methods

dispatchDraw

Added in API level 11
void dispatchDraw (Canvas canvas)

通过绘制来绘制子视图。 这可能会被派生类重写,以便在子对象被绘制之前获得控制权(但在绘制自己的视图之后)。

Parameters
canvas Canvas: the canvas on which to draw the view

onLayout

Added in API level 11
void onLayout (boolean changed, 
                int left, 
                int top, 
                int right, 
                int bottom)

当这个视图为每个孩子分配一个大小和位置时,从布局调用。 带孩子的派生类应该覆盖这个方法,并调用他们每个孩子的布局。

Parameters
changed boolean: This is a new size or position for this view
left int: Left position, relative to parent
top int: Top position, relative to parent
right int: Right position, relative to parent
bottom int: Bottom position, relative to parent

onMeasure

Added in API level 11
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!