Most visited

Recently visited

ActionMenuView

public class ActionMenuView
extends LinearLayoutCompat

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.support.v7.widget.LinearLayoutCompat
         ↳ android.support.v7.widget.ActionMenuView


ActionMenuView是一系列作为视图的菜单选项的演示文稿。 它提供了几个顶级选项作为操作按钮,同时溢出菜单中的剩余选项作为项目。 这使得应用程序可以呈现与特定或重复内容内联的行为包。

Summary

Nested classes

class ActionMenuView.LayoutParams

 

interface ActionMenuView.OnMenuItemClickListener

如果项目本身没有单独的项目点击监听器,则负责接收菜单项点击事件。

Inherited XML attributes

From class android.view.ViewGroup
From class android.view.View

Inherited constants

From class android.support.v7.widget.LinearLayoutCompat
From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

ActionMenuView(Context context)
ActionMenuView(Context context, AttributeSet attrs)

Public methods

void dismissPopupMenus()

关闭与此菜单视图关联的任何弹出窗口。

boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event)

首先将 AccessibilityEventView ,然后分配给其子项,以将其文本内容添加到事件中。

ActionMenuView.LayoutParams generateLayoutParams(AttributeSet attrs)

根据提供的属性集返回一组新的布局参数。

Menu getMenu()

返回此ActionMenuView当前呈现的Menu对象。

Drawable getOverflowIcon()

返回用作溢出图标的当前绘图。

int getPopupTheme()
boolean hideOverflowMenu()

隐藏相关菜单中的溢出项目。

boolean isOverflowMenuShowing()

检查当前是否显示溢出菜单。

void onConfigurationChanged(Configuration newConfig)

当应用程序使用的资源的当前配置发生更改时调用。

void onDetachedFromWindow()

这是在视图从窗口分离时调用的。

void setOnMenuItemClickListener(ActionMenuView.OnMenuItemClickListener listener)
void setOverflowIcon(Drawable icon)

设置用于溢出按钮的图标。

void setPopupTheme(int resId)

指定充气弹出菜单时要使用的主题。

boolean showOverflowMenu()

显示相关菜单中的溢出项目。

Protected methods

boolean checkLayoutParams(ViewGroup.LayoutParams p)
ActionMenuView.LayoutParams generateDefaultLayoutParams()

当布局的方向为 VERTICAL时,返回一组宽度为 MATCH_PARENT和高度为 WRAP_CONTENT的布局 VERTICAL

ActionMenuView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)

根据提供的布局参数返回一组安全的布局参数。

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

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

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

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

Inherited methods

From class android.support.v7.widget.LinearLayoutCompat
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
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

ActionMenuView

ActionMenuView (Context context)

Parameters
context Context

ActionMenuView

ActionMenuView (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

Public methods

dismissPopupMenus

void dismissPopupMenus ()

关闭与此菜单视图关联的任何弹出窗口。

dispatchPopulateAccessibilityEvent

boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)

首先将AccessibilityEventView ,然后分配给其子项以将其文本内容添加到事件中。 请注意,事件文本是在单独的调度路径中填充的,因为我们不仅将源文本添加到事件中,而且还添加其所有后代的文本。 一个典型的实现将在这个视图上调用onPopulateAccessibilityEvent(AccessibilityEvent) ,然后在每个孩子上调用dispatchPopulateAccessibilityEvent(AccessibilityEvent) 如果需要事件文本内容的自定义填充,则覆盖此方法。

如果 View.AccessibilityDelegate已通过呼叫 setAccessibilityDelegate(AccessibilityDelegate)指定, setAccessibilityDelegate(AccessibilityDelegate)dispatchPopulateAccessibilityEvent(View, AccessibilityEvent)负责处理此呼叫。

注意:某些类型的辅助功能事件不会通过此方法分派用于填充事件文本。 有关详细信息,请参阅AccessibilityEvent

Parameters
event AccessibilityEvent: The event.
Returns
boolean True if the event population was completed.

generateLayoutParams

ActionMenuView.LayoutParams generateLayoutParams (AttributeSet attrs)

根据提供的属性集返回一组新的布局参数。

Parameters
attrs AttributeSet: the attributes to build the layout parameters from
Returns
ActionMenuView.LayoutParams an instance of ViewGroup.LayoutParams or one of its descendants

getMenu

Menu getMenu ()

返回此ActionMenuView当前呈现的Menu对象。

应用程序应该使用此方法获取ActionMenuView的Menu对象,并根据需要给它添加或添加内容。

Returns
Menu the Menu presented by this view

getOverflowIcon

Drawable getOverflowIcon ()

返回用作溢出图标的当前绘图。

Returns
Drawable The overflow icon drawable

getPopupTheme

int getPopupTheme ()

Returns
int resource identifier of the theme used to inflate popup menus, or 0 if menus are inflated against the action menu view theme

也可以看看:

hideOverflowMenu

boolean hideOverflowMenu ()

隐藏相关菜单中的溢出项目。

Returns
boolean true if the menu was able to be hidden, false otherwise

isOverflowMenuShowing

boolean isOverflowMenuShowing ()

检查当前是否显示溢出菜单。 这可能不会反映正在进行的待处理演出操作。

Returns
boolean true if the overflow menu is currently showing

onConfigurationChanged

void onConfigurationChanged (Configuration newConfig)

当应用程序使用的资源的当前配置发生更改时调用。 您可以使用它来决定何时重新加载可根据方向和其他配置特性更改的资源。 如果您不依赖正常的配置更改时重新创建活动实例的Activity机制,则只需要使用它。

Parameters
newConfig Configuration: The new resource configuration.

onDetachedFromWindow

void onDetachedFromWindow ()

这是在视图从窗口分离时调用的。 此时它不再有绘图表面。

setOnMenuItemClickListener

void setOnMenuItemClickListener (ActionMenuView.OnMenuItemClickListener listener)

Parameters
listener ActionMenuView.OnMenuItemClickListener

setOverflowIcon

void setOverflowIcon (Drawable icon)

设置用于溢出按钮的图标。

Parameters
icon Drawable: Drawable to set, may be null to clear the icon

setPopupTheme

void setPopupTheme (int resId)

指定充气弹出菜单时要使用的主题。 默认情况下,使用与操作菜单视图本身相同的主题。

Parameters
resId int: theme used to inflate popup menus

也可以看看:

showOverflowMenu

boolean showOverflowMenu ()

显示相关菜单中的溢出项目。

Returns
boolean true if the menu was able to be shown, false otherwise

Protected methods

checkLayoutParams

boolean checkLayoutParams (ViewGroup.LayoutParams p)

Parameters
p ViewGroup.LayoutParams
Returns
boolean

generateDefaultLayoutParams

ActionMenuView.LayoutParams generateDefaultLayoutParams ()

当布局的方向为VERTICAL时,返回一组宽度为MATCH_PARENT ,高度为WRAP_CONTENT的布局VERTICAL 当方向为HORIZONTAL ,宽度设置为WRAP_CONTENT ,高度为WRAP_CONTENT

Returns
ActionMenuView.LayoutParams a set of default layout parameters or null

generateLayoutParams

ActionMenuView.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)

根据提供的布局参数返回一组安全的布局参数。 当一个ViewGroup被传递了一个View,其布局参数没有通过checkLayoutParams(android.view.ViewGroup.LayoutParams)的测试时,这个方法被调用。 此方法应该返回一组适合此ViewGroup的布局参数,可能是通过从指定的一组布局参数中复制适当的属性。

Parameters
p ViewGroup.LayoutParams: The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Returns
ActionMenuView.LayoutParams an instance of ViewGroup.LayoutParams or one of its descendants

onLayout

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

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!