ScrollView滚动视图.docx

上传人:b****6 文档编号:6620991 上传时间:2023-01-08 格式:DOCX 页数:21 大小:24.36KB
下载 相关 举报
ScrollView滚动视图.docx_第1页
第1页 / 共21页
ScrollView滚动视图.docx_第2页
第2页 / 共21页
ScrollView滚动视图.docx_第3页
第3页 / 共21页
ScrollView滚动视图.docx_第4页
第4页 / 共21页
ScrollView滚动视图.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

ScrollView滚动视图.docx

《ScrollView滚动视图.docx》由会员分享,可在线阅读,更多相关《ScrollView滚动视图.docx(21页珍藏版)》请在冰豆网上搜索。

ScrollView滚动视图.docx

ScrollView滚动视图

ScrollView滚动视图

extendsFrameLayout

java.lang.Object

↳android.view.View

↳android.view.ViewGroup

↳android.widget.FrameLayout

↳android.widget.ScrollView

ClassOverview

Layoutcontainerforaviewhierarchythatcanbescrolledbytheuser,allowingittobelargerthanthephysicaldisplay.AScrollViewisaFrameLayout,meaningyoushouldplaceonechildinitcontainingtheentirecontentstoscroll;thischildmayitselfbealayoutmanagerwithacomplexhierarchyofobjects.AchildthatisoftenusedisaLinearLayoutinaverticalorientation,presentingaverticalarrayoftop-levelitemsthattheusercanscrollthrough.

YoushouldneveruseaScrollViewwithaListView,becauseListViewtakescareofitsownverticalscrolling.Mostimportantly,doingthisdefeatsalloftheimportantoptimizationsinListViewfordealingwithlargelists,sinceiteffectivelyforcestheListViewtodisplayitsentirelistofitemstofilluptheinfinitecontainersuppliedbyScrollView.

TheTextViewclassalsotakescareofitsownscrolling,sodoesnotrequireaScrollView,butusingthetwotogetherispossibletoachievetheeffectofatextviewwithinalargercontainer.

ScrollViewonlysupportsverticalscrolling.Forhorizontalscrolling,useHorizontalScrollView.

Summary

XMLAttributes

AttributeNameRelatedMethodDescription

android:

fillViewportsetFillViewport(boolean)Defineswhetherthescrollviewshouldstretchitscontenttofilltheviewport.

[Expand]

InheritedXMLAttributes

Fromclassandroid.widget.FrameLayout

Fromclassandroid.view.ViewGroup

Fromclassandroid.view.View

[Expand]

InheritedConstants

Fromclassandroid.view.ViewGroup

Fromclassandroid.view.View

[Expand]

InheritedFields

Fromclassandroid.view.View

PublicConstructors

ScrollView(Contextcontext)

ScrollView(Contextcontext,AttributeSetattrs)

ScrollView(Contextcontext,AttributeSetattrs,intdefStyleAttr)

ScrollView(Contextcontext,AttributeSetattrs,intdefStyleAttr,intdefStyleRes)

PublicMethods

voidaddView(Viewchild,intindex)

Addsachildview.

voidaddView(Viewchild,intindex,ViewGroup.LayoutParamsparams)

Addsachildviewwiththespecifiedlayoutparameters.

voidaddView(Viewchild)

Addsachildview.

voidaddView(Viewchild,ViewGroup.LayoutParamsparams)

Addsachildviewwiththespecifiedlayoutparameters.

booleanarrowScroll(intdirection)

Handlescrollinginresponsetoanupordownarrowclick.

voidcomputeScroll()

CalledbyaparenttorequestthatachildupdateitsvaluesformScrollXandmScrollYifnecessary.

booleandispatchKeyEvent(KeyEventevent)

Dispatchakeyeventtothenextviewonthefocuspath.

voiddraw(Canvascanvas)

Manuallyrenderthisview(andallofitschildren)tothegivenCanvas.

booleanexecuteKeyEvent(KeyEventevent)

Youcancallthisfunctionyourselftohavethescrollviewperformscrollingfromakeyevent,justasiftheeventhadbeendispatchedtoitbytheviewhierarchy.

voidfling(intvelocityY)

Flingthescrollview

booleanfullScroll(intdirection)

Handlesscrollinginresponsetoa"home/end"shortcutpress.

CharSequencegetAccessibilityClassName()

Returntheclassnameofthisobjecttobeusedforaccessibilitypurposes.

intgetMaxScrollAmount()

booleanisFillViewport()

IndicateswhetherthisScrollView'scontentisstretchedtofilltheviewport.

booleanisSmoothScrollingEnabled()

booleanonGenericMotionEvent(MotionEventevent)

Implementthismethodtohandlegenericmotionevents.

booleanonInterceptTouchEvent(MotionEventev)

Implementthismethodtointerceptalltouchscreenmotionevents.

booleanonNestedFling(Viewtarget,floatvelocityX,floatvelocityY,booleanconsumed)

Requestaflingfromanestedscroll.

voidonNestedScroll(Viewtarget,intdxConsumed,intdyConsumed,intdxUnconsumed,intdyUnconsumed)

Reacttoanestedscrollinprogress.

voidonNestedScrollAccepted(Viewchild,Viewtarget,intaxes)

Reacttothesuccessfulclaimingofanestedscrolloperation.

booleanonStartNestedScroll(Viewchild,Viewtarget,intnestedScrollAxes)

Reacttoadescendantviewinitiatinganestablescrolloperation,claimingthenestedscrolloperationifappropriate.

voidonStopNestedScroll(Viewtarget)

Reacttoanestedscrolloperationending.

booleanonTouchEvent(MotionEventev)

Implementthismethodtohandletouchscreenmotionevents.

booleanpageScroll(intdirection)

Handlesscrollinginresponsetoa"pageup/down"shortcutpress.

voidrequestChildFocus(Viewchild,Viewfocused)

Calledwhenachildofthisparentwantsfocus

booleanrequestChildRectangleOnScreen(Viewchild,Rectrectangle,booleanimmediate)

Calledwhenachildofthisgroupwantsaparticularrectangletobepositionedontothescreen.

voidrequestDisallowInterceptTouchEvent(booleandisallowIntercept)

CalledwhenachilddoesnotwantthisparentanditsancestorstointercepttoucheventswithonInterceptTouchEvent(MotionEvent).

voidrequestLayout()

Callthiswhensomethinghaschangedwhichhasinvalidatedthelayoutofthisview.

voidscrollTo(intx,inty)

Setthescrolledpositionofyourview.

Thisversionalsoclampsthescrollingtotheboundsofourchild.

voidsetFillViewport(booleanfillViewport)

IndicatesthisScrollViewwhetheritshouldstretchitscontentheighttofilltheviewportornot.

voidsetOverScrollMode(intmode)

Settheover-scrollmodeforthisview.

voidsetSmoothScrollingEnabled(booleansmoothScrollingEnabled)

Setwhetherarrowscrollingwillanimateitstransition.

booleanshouldDelayChildPressedState()

ReturntrueifthepressedstateshouldbedelayedforchildrenordescendantsofthisViewGroup.

finalvoidsmoothScrollBy(intdx,intdy)

LikescrollBy(int,int),butscrollsmoothlyinsteadofimmediately.

finalvoidsmoothScrollTo(intx,inty)

LikescrollTo(int,int),butscrollsmoothlyinsteadofimmediately.

ProtectedMethods

intcomputeScrollDeltaToGetChildRectOnScreen(Rectrect)

ComputetheamounttoscrollintheYdirectioninordertogetarectanglecompletelyonthescreen(or,iftallerthanthescreen,atleastthefirstscreensizechunkofit).

intcomputeVerticalScrollOffset()

Computetheverticaloffsetoftheverticalscrollbar'sthumbwithinthehorizontalrange.

intcomputeVerticalScrollRange()

Thescrollrangeofascrollviewistheoverallheightofallofitschildren.

floatgetBottomFadingEdgeStrength()

Returnsthestrength,orintensity,ofthebottomfadededge.

floatgetTopFadingEdgeStrength()

Returnsthestrength,orintensity,ofthetopfadededge.

voidmeasureChild(Viewchild,intparentWidthMeasureSpec,intparentHeightMeasureSpec)

Askoneofthechildrenofthisviewtomeasureitself,takingintoaccountboththeMeasureSpecrequirementsforthisviewanditspadding.

voidmeasureChildWithMargins(Viewchild,intparentWidthMeasureSpec,intwidthUsed,intparentHeightMeasureSpec,intheightUsed)

Askoneofthechildrenofthisviewtomeasureitself,takingintoaccountboththeMeasureSpecrequirementsforthisviewanditspaddingandmargins.

voidonDetachedFromWindow()

Thisiscalledwhentheviewisdetachedfromawindow.

voidonLayout(booleanchanged,intl,intt,intr,intb)

Calledfromlayoutwhenthisviewshouldassignasizeandpositiontoeachofitschildren.

voidonMeasure(intwidthMeasureSpec,intheightMeasureSpec)

Measuretheviewanditscontenttodeterminethemeasuredwidthandthemeasuredheight.

voidonOverScrolled(intscrollX,intscrollY,booleanclampedX,booleanclampedY)

CalledbyoverScrollBy(int,int,int,int,int,int,int,int,boolean)torespondtotheresultsofanover-scrolloperation.

booleanonRequestFocusInDescendants(intdirection,RectpreviouslyFocusedRect)

Whenlookingforfocusinchildrenofascrollview,needtobealittlemorecarefulnottogivefocustosomethingthatisscrolledoffscreen.

voidonRestoreInstanceState(Parcelablestate)

Hookallowingaviewtore-applyarepresentationofitsinternalstatethathadpreviouslybeengeneratedbyonSaveInstanceState().

ParcelableonSaveInstanceState()

Hookallowingaviewtogeneratearepresentationofitsinternalstatethatcanlaterbeusedtocreateanewinstancewiththatsamestate.

voidonSizeChanged(intw,inth,intoldw,intoldh)

Thisiscalledduringlayoutwhenthesizeofthisviewhaschanged.

[Expand]

InheritedMethods

Fromclassandroid.widget.FrameLayout

Fromclassandroid.view.ViewGroup

Fromclassandroid.view.View

Fromclassjava.lang.Object

Frominterfaceandroid.view.ViewParent

Frominterfaceandroid.view.ViewManager

Frominterfaceandroid.graphics.drawable.Drawable.Callback

Frominterfaceandroid.view.KeyEvent.Callback

Frominterfaceandroid.view.accessibility.AccessibilityEventSource

XMLAttributes

android:

fillViewport

Defineswhetherthescrollviewshouldstretchitscontenttofilltheviewport.

Mustbeabooleanvalue,either"true"or"false".

Thismayalsobeareferencetoaresource(intheform"@[package:

]type:

name")orthemeattribute(intheform"?

[package:

][type:

]name")containingavalueofthistype.

ThiscorrespondstotheglobalattributeresourcesymbolfillViewport.

RelatedMethods

setFillViewport(boolean)

PublicConstructors

publicScrollView(Contextcontext)

AddedinAPIlevel1

publicScrollView(Contextcontext,AttributeSetattrs)

AddedinAPIlevel1

publicScrollView(Contextcontext,AttributeSetattrs,intdefStyleAttr)

AddedinAPIlevel1

publicScrollView(Contextcontext,AttributeSetattrs,intdefStyleAttr,intdefStyleRes)

AddedinAPIlevel21

PublicMethods

publicvoidaddView(Viewchild,intindex)

AddedinAPIlevel1

Addsachildview.Ifnolayoutparametersarealreadysetonthechild,thedefaultparametersforthisViewGrouparesetonth

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 交通运输

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1