horizontalscrollview
完整内容,请查看:http://www.zhdoc.net/Android/reference/android/widget/horizontalscrollview.html
HorizontalScrollView
public class HorizontalScrollView
extends
Framelayout
java.lang.Object | ||||
↳ | android.view.View | |||
↳ | android.view.ViewGroup | |||
↳ | android.widget.FrameLayout | |||
↳ | android.widget.HorizontalScrollView |
已知的直接子类
TabLayout |
Layout container for a view hierarchy that can be scrolled by the user, allowing it to be larger than the physical display. A HorizontalScrollView is a
FrameLayout
, meaning you should place one child in it containing the entire contents to scroll; this child may itself be a layout manager with
a complex hierarchy of objects. A child that is often used is a LinearLayout
in a horizontal orientation, presenting a horizontal array of top-level
items that the user can scroll through.
视图层次结构的布局容器,可以由用户进行滚动,允许它的内容比物理显示屏更大。HorizontalScrollView是一个FrameLayout
,这意味着你应该在其中放置一个子项来滚动,其包含了所有的内容;这个子项本身可能是一个具有复杂的对象层次结构的布局管理器。子项经常在水平方位中,使用一个LinearLayout
,其呈现了一个顶层项的水平排列,用户可以滚动浏览。
The TextView
class also takes care of its own scrolling, so does not require a HorizontalScrollView, but using the two together is possible to
achieve the effect of a text view within a larger container.
TextView
类也负责它自己的滚动,因此不需要HorizontalScrollView,但是同时使用,可以实现在较大容器中的显示文本视图的效果。
HorizontalScrollView only supports horizontal scrolling. For vertical scrolling, use either
ScrollView
or
listview
.
HorizontalScrollView只支持水平方向的滚动。对于垂直方向的滚动,请使用哦那个ScrollView
或ListView
。
摘要
XML属性 |
|
---|---|
android:fillViewport |
设置scrollview是否应拉伸其内容以填充可视区域。 |
继承XML属性 |
|
---|---|
From
class android.widget.FrameLayout
|
|
From
class android.view.ViewGroup
|
|
From
class android.view.View
|
继承常量 |
---|
From
class android.view.ViewGroup
|
From
class android.view.View
|
继承字段 |
---|
From
class android.view.View
|
Public构造方法 |
|
---|---|
HorizontalScrollView(context
context) |
|
HorizontalScrollView(Context
context,
AttributeSet attrs) |
|
HorizontalScrollView(Context
context,
AttributeSet attrs, int defStyleAttr) |
|
HorizontalScrollView(Context
context,
AttributeSet attrs, int defStyleAttr, int defStyleRes) |
Public方法 |
|
---|---|
void |
addView(View
child, int index)
Adds a child view. 添加一个子视图。 |
void |
addView(View
child)
Adds a child view. 添加一个子视图。 |
void |
addView(View
child,
ViewGroup.layoutparams params)
Adds a child view with the specified layout parameters. 添加具有指定布局参数的子视图。 |
void |
addView(View
child, int index,
ViewGroup.LayoutParams params)
Adds a child view with the specified layout parameters. 添加具有指定布局参数的子视图。 |
boolean |
arrowScroll(int direction)
handle scrolling in response to a left or right arrow click. 处理左右箭头键的滚动。 |
void |
computeScroll()
Called by a parent to request that a child update its values for mScrollX and mScrollY if necessary. 由父项调用, 以请求子项在必要时,更新mScrollX和mScrollY的值。 |
boolean |
dispatchKeyEvent(KeyEvent
event)
Dispatch a key event to the next view on the focus path. 向焦点路径上的下一个视图派发一个KeyEvent。 |
void |
draw(Canvas
canvas)
Manually render this view (and all of its children) to the given Canvas. 手动将此视图 (及其所有子项) 渲染到指定的Canvas。 |
boolean |
executeKeyEvent(KeyEvent
event)
You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the event had been dispatched to it by the view hierarchy. |
void |
fling(int velocityX)
Fling the scroll view Fling滚动视图 |
boolean |
fullScroll(int direction)
Handles scrolling in response to a "home/end" shortcut press. 处理按下“home/end”快捷键的滚动。 |
Charsequence |
getAccessibilityClassName()
Return the class name of this object to be used for accessibility purposes. 返回此对象的类名,用于辅助功能目的。 |
int |
getMaxScrollAmount()
|
boolean |
isFillViewport()
Indicates whether this HorizontalScrollView's content is stretched to fill the viewport. 这个HorizontalScrollView的内容是否被拉伸,以填充视口(viewport)。 |
boolean |
isSmoothScrollingEnabled()
|
boolean |
onGenericmotionevent(MotionEvent
event)
Implement this method to handle generic motion events. 实现此方法以处理普通的MotionEvent。 |
boolean |
onInterceptTouchEvent(MotionEvent
ev)
Implement this method to intercept all touch screen motion events. 实现此方法可拦截所有触摸屏MotionEvent。 |
boolean |
onTouchEvent(MotionEvent
ev)
Implement this method to handle touch screen motion events. 实现此方法,以处理触摸屏的MotionEvent。 |
boolean |
pageScroll(int direction)
Handles scrolling in response to a "page up/down" shortcut press. 处理按下“page up/down”快捷键的滚动。 |
void |
requestChildFocus(View
child,
View focused)
Called when a child of this parent wants focus 当此父项的子项请求焦点时调用。 |
boolean |
requestChildRectangleOnScreen(View
child,
Rect rectangle, boolean immediate)
Called when a child of this group wants a particular rectangle to be positioned onto the screen. 当此组的子项希望将特定的矩形置于屏幕上时调用。 |
void |
requestDisallowInterceptTouchEvent(boolean disallowIntercept)
Called when a child does not want this parent and its ancestors to intercept touch events with
当一个子项不希望此父项,通过 |
void |
requestLayout()
Call this when something has changed which has invalidated the layout of this view. 当使此视图的布局失效事件发生时, 调用此方法。 |
void |
scrollTo(int x, int y)
Set the scrolled position of your view. 设置此视图到滚动位置。 This version also clamps the scrolling to the bounds of our child. 这个版本还将控制滚动到子项的边界。 |
void |
setFillViewport(boolean fillViewport)
Indicates this HorizontalScrollView whether it should stretch its content width to fill the viewport or not. 此HorizontalScrollView 是否应该拉伸它的内容宽度来填充视口(viewport)。 |
void |
setOverScrollMode(int mode)
Set the over-scroll mode for this view. 设置此视图的over-scroll模式。 |
void |
setSmoothScrollingEnabled(boolean smoothScrollingEnabled)
Set whether arrow scrolling will animate its transition. 设置箭头滚动是否使用动画转换。 |
boolean |
shouldDelayChildPressedState()
Return true if the pressed state should be delayed for children or descendants of this ViewGroup. 如果这个ViewGroup的子项要延迟按下的状态,则返回true。 |
final void |
smoothScrollBy(int dx, int dy)
Like 和 |
final void |
smoothScrollTo(int x, int y)
Like 和 |
保护方法
完整内容,请查看:http://www.zhdoc.net/android/reference/android/widget/HorizontalScrollView.html
相关阅读
横向滑动视图HorizontalScrollView精炼详解
一、前期基础知识储备 由于移动设备物理显示空间一般有限,不可能一次性的把所有要显示的内容都显示在屏幕上。所以各大平台一般会