A view that shows items in a center-locked, horizontally scrolling list.
The default values for the Gallery assume you will be using Theme_galleryItemBackground as the background for each View given to the Gallery from the Adapter. If you are not doing this, you may need to adjust some Gallery properties, such as the spacing.
Gallery.LayoutParams | Gallery extends LayoutParams to provide a place to hold current Transformation information along with previous position/transformation info. |
Attribute name | Related methods | |
---|---|---|
android:animationDuration | setAnimationDuration(int) |
Sets how long a transition animation should run (in milliseconds) when layout has changed. |
android:gravity | setGravity(int) |
Specifies how to place an object, both its x and y axis, within a larger containing object. |
android:spacing | setSpacing(int) |
|
android:unselectedAlpha | setUnselectedAlpha(float) |
Sets the alpha on the items that are not selected. |
Gallery(Context context) | ||||||
Gallery(Context context, AttributeSet attrs) | ||||||
Gallery(Context context, AttributeSet attrs, int defStyle) |
boolean | dispatchKeyEvent(KeyEvent event) | |||||
Dispatch a key event to the next view on the focus path. | ||||||
void | dispatchSetSelected(boolean selected) | |||||
Dispatch setSelected to all of this View's children. | ||||||
ViewGroup.LayoutParams | generateLayoutParams(AttributeSet attrs) | |||||
Returns a new set of layout parameters based on the supplied attributes set. | ||||||
boolean | onDown(MotionEvent e) | |||||
Notified when a tap occurs with the down MotionEvent that triggered it. | ||||||
boolean | onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) | |||||
Notified of a fling event when it occurs with the initial on down MotionEvent and the matching up MotionEvent. | ||||||
boolean | onKeyDown(int keyCode, KeyEvent event) | |||||
Handles left, right, and clicking | ||||||
boolean | onKeyUp(int keyCode, KeyEvent event) | |||||
Default implementation of KeyEvent.Callback.onKeyMultiple(): perform clicking of the view when KEYCODE_DPAD_CENTER or KEYCODE_ENTER is released. | ||||||
void | onLongPress(MotionEvent e) | |||||
Notified when a long press occurs with the initial on down MotionEvent that trigged it. | ||||||
boolean | onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) | |||||
Notified when a scroll occurs with the initial on down MotionEvent and the current move MotionEvent. | ||||||
void | onShowPress(MotionEvent e) | |||||
The user has performed a down MotionEvent and not performed a move or up yet. | ||||||
boolean | onSingleTapUp(MotionEvent e) | |||||
Notified when a tap occurs with the up MotionEvent that triggered it. | ||||||
boolean | onTouchEvent(MotionEvent event) | |||||
Implement this method to handle touch screen motion events. | ||||||
void | setAnimationDuration(int animationDurationMillis) | |||||
Sets how long the transition animation should run when a child view changes position. | ||||||
void | setCallbackDuringFling(boolean shouldCallback) | |||||
Whether or not to callback on any getOnItemSelectedListener() while the items are being flinged. | ||||||
void | setGravity(int gravity) | |||||
Describes how the child views are aligned. | ||||||
void | setSpacing(int spacing) | |||||
Sets the spacing between items in a Gallery | ||||||
void | setUnselectedAlpha(float unselectedAlpha) | |||||
Sets the alpha of items that are not selected in the Gallery. | ||||||
boolean | showContextMenu() | |||||
Bring up the context menu for this view. | ||||||
boolean | showContextMenuForChild(View originalView) | |||||
Bring up a context menu for the specified view or its ancestors. |
boolean | checkLayoutParams(ViewGroup.LayoutParams p) | |||||
int | computeHorizontalScrollExtent() | |||||
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range. |
||||||
int | computeHorizontalScrollOffset() | |||||
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. |
||||||
int | computeHorizontalScrollRange() | |||||
Compute the horizontal range that the horizontal scrollbar represents. |
||||||
void | dispatchSetPressed(boolean pressed) | |||||
Dispatch setPressed to all of this View's children. | ||||||
ViewGroup.LayoutParams | generateDefaultLayoutParams() | |||||
Returns a set of default layout parameters. | ||||||
ViewGroup.LayoutParams | generateLayoutParams(ViewGroup.LayoutParams p) | |||||
Returns a safe set of layout parameters based on the supplied layout params. | ||||||
int | getChildDrawingOrder(int childCount, int i) | |||||
Returns the index of the child to draw for this iteration. | ||||||
boolean | getChildStaticTransformation(View child, Transformation t) | |||||
ContextMenu.ContextMenuInfo | getContextMenuInfo() | |||||
Views should implement this if they have extra information to associate with the context menu. | ||||||
void | onFocusChanged(boolean gainFocus, int direction, Rect previouslyFocusedRect) | |||||
Called by the view system when the focus state of this view changes. | ||||||
void | onLayout(boolean changed, int l, int t, int r, int b) | |||||
Called from layout when this view should assign a size and position to each of its children. |
Must be an integer value, such as "100
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol animationDuration.
Must be one or more (separated by '|') of the following constant values.
Constant | Value | Description |
---|---|---|
top | 0x30 | Push object to the top of its container, not changing its size. |
bottom | 0x50 | Push object to the bottom of its container, not changing its size. |
left | 0x03 | Push object to the left of its container, not changing its size. |
right | 0x05 | Push object to the right of its container, not changing its size. |
center_vertical | 0x10 | Place object in the vertical center of its container, not changing its size. |
fill_vertical | 0x70 | Grow the vertical size of the object if needed so it completely fills its container. |
center_horizontal | 0x01 | Place object in the horizontal center of its container, not changing its size. |
fill_horizontal | 0x07 | Grow the horizontal size of the object if needed so it completely fills its container. |
center | 0x11 | Place the object in the center of its container in both the vertical and horizontal axis, not changing its size. |
fill | 0x77 | Grow the horizontal and vertical size of the object if needed so it completely fills its container. |
This corresponds to the global attribute resource symbol gravity.
Must be a floating point value, such as "1.2
".
This may also be a reference to a resource (in the form
"@[package:]type:name
") or
theme attribute (in the form
"?[package:][type:]name
")
containing a value of this type.
This corresponds to the global attribute resource symbol unselectedAlpha.
event | The key event to be dispatched. |
---|
selected | The new selected state |
---|
attrs | the attributes to build the layout parameters from |
---|
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
keyCode | A key code that represents the button pressed, from KeyEvent. |
---|---|
event | The KeyEvent object that defines the button action. |
event | The motion event. |
---|
animationDurationMillis | The duration of the transition, in milliseconds. |
---|
shouldCallback | Whether or not to callback on the listener while the items are being flinged. |
---|
spacing | The spacing in pixels between items in the Gallery |
---|
unselectedAlpha | the alpha for the items that are not selected. |
---|
In most cases, a subclass does not need to override this. However, if the subclass is added directly to the window manager (for example, addView(View, android.view.ViewGroup.LayoutParams)) then it should override this and show the context menu.
Compute the horizontal extent of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the length of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeHorizontalScrollOffset().
The default extent is the drawing width of this view.
Compute the horizontal offset of the horizontal scrollbar's thumb within the horizontal range. This value is used to compute the position of the thumb within the scrollbar's track.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollRange() and computeHorizontalScrollExtent().
The default offset is the scroll offset of this view.
Compute the horizontal range that the horizontal scrollbar represents.
The range is expressed in arbitrary units that must be the same as the units used by computeHorizontalScrollExtent() and computeHorizontalScrollOffset().
The default range is the drawing width of this view.
pressed | The new pressed state |
---|
p | The layout parameters to convert into a suitable set of layout parameters for this ViewGroup. |
---|
NOTE: In order for this method to be called, the FLAG_USE_CHILD_DRAWING_ORDER must be set.
i | The current iteration. |
---|
gainFocus | True if the View has focus; false otherwise. |
---|---|
direction | The direction focus has moved when requestFocus() is called to give this view focus. Values are View.FOCUS_UP, View.FOCUS_DOWN, View.FOCUS_LEFT or View.FOCUS_RIGHT. It may not always apply, in which case use the default. |
previouslyFocusedRect | The rectangle, in this view's coordinate
system, of the previously focused view. If applicable, this will be
passed in as finer grained information about where the focus is coming
from (in addition to direction). Will be null otherwise.
|
changed | This is a new size or position for this view |
---|---|
l | Left position, relative to parent |
t | Top position, relative to parent |
r | Right position, relative to parent |
b | Bottom position, relative to parent |
Copyright 2007 Google Inc. | Build 0.9_r1-98467 - 14 Aug 2008 18:48 |