SoftKeyboard示例之CandidateView详解
工程的包名:com.example.android.softkeyboard.
CandidateView.CandidateView(Context context)
- Construct a CandidateView for showing suggested words for completion.
android.view.GestureDetector.GestureDetector(OnGestureListener listener)
Deprecated. Use GestureDetector(android.content.Context, android.view.GestureDetector.OnGestureListener) instead.
释义:
- Creates a GestureDetector with the supplied listener.
- You may only use this constructor from a UI thread (this is the usual situation).
参数:
- listener the listener invoked for all the callbacks, this must not be null.
异常:
- NullPointerException - if listener is null.
android.view.GestureDetector.SimpleOnGestureListener
- A convenience class to extend when you only want to listen for a subset of all the gestures.
- This implements all methods in the OnGestureListener and OnDoubleTapListener but does nothing and return false for all applicable methods.
SimpleOnGestureListener.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.
- The distance in x and y is also supplied for convenience.
参数:
- e1 The first down motion event that started the scrolling.
- e2 The move motion event that triggered the current onScroll.
- distanceX The distance along the X axis(轴) that has been scrolled since the last call to onScroll.
- distanceY The distance along the Y axis that has been scrolled since the last call to onScroll.
返回:
- true if the event is consumed(消耗、毁灭), else false
void android.view.View.setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled)
释义:
- Define whether the horizontal edges(边缘) should be faded(褪色、凋谢) when this view is scrolled horizontally.
参数:
- horizontalFadingEdgeEnabled true if the horizontal edges should be faded when the view is scrolled horizontally
void android.view.View.setWillNotDraw(boolean willNotDraw)
释义:
- If this view doesn't do any drawing on its own, set this flag to allow further optimizations(优化计算).
- By default, this flag is not set on View, but could be set on some View subclasses such as ViewGroup.
- Typically, if you override onDraw(android.graphics.Canvas) you should clear this flag.
参数:
- willNotDraw whether or not this View draw on its own
void android.view.View.setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled)
释义:
- Define whether the horizontal scrollbar should be drawn or not.
- The scrollbar is not drawn by default.
参数:
- horizontalScrollBarEnabled true if the horizontal scrollbar should be painted
See Also:
- isHorizontalScrollBarEnabled()
void android.view.View.setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled)
释义:
- Define whether the vertical scrollbar should be drawn or not.
- The scrollbar is not drawn by default.
参数:
- verticalScrollBarEnabled true if the vertical scrollbar should be painted
See Also:
- isVerticalScrollBarEnabled()
int android.view.View.getScrollX()
释义:
- Return the scrolled left position of this view.
- This is the left edge of the displayed part of your view.
- You do not need to draw any pixels farther left, since those are outside of the frame of your view on screen.
返回:
- The left edge of the displayed part of your view, in pixels.
int android.view.View.getWidth()
释义:
- Return the width of the your view.
返回:
- The width of your view, in pixels.
void android.view.View.scrollTo(int x, int y)
释义:
- Set the scrolled position of your view. This will cause a call to onScrollChanged(int, int, int, int) and the view will be invalidated.
参数:
- x the x position to scroll to
- y the y position to scroll to
int android.view.View.getScrollY()
释义:
- Return the scrolled top position of this view.
- This is the top edge of the displayed part of your view.
- You do not need to draw any pixels above it, since those are outside of the frame of your view on screen.
返回:
- The top edge of the displayed part of your view, in pixels.
void android.view.View.invalidate()
释义:
- Invalidate the whole view.
- If the view is visible, onDraw(android.graphics.Canvas) will be called at some point in the future.
- This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().
void android.view.View.setBackgroundColor(int color)
释义:
- Sets the background color for this view.
参数:
- color the color of the background
int android.content.res.Resources.getColor(int id) throws NotFoundException
释义:
- Return a color integer associated with a particular resource ID.
- If the resource holds a complex android.content.res.ColorStateList, then the default color from the set is returned.
参数:
- id The desired resource identifier, as generated by the aapt tool. This integer encodes the package, type, and resource entry. The value 0 is an invalid identifier.
返回:
- Returns a single color value in the form 0xAARRGGBB.
异常:
- NotFoundException - Throws NotFoundException if the given ID does not exist.
android.graphics.Paint.Paint()
释义:
- Create a new paint with default settings.
void android.graphics.Paint.setColor(int color)
释义:
- Set the paint's color.
- Note that the color is an int containing alpha(颜色的alpha值) as well as r,g,b.
- This 32bit value is not premultiplied(自左乘), meaning that its alpha can be any value, regardless of the values of r,g,b.
参数:
- color The new color (including alpha) to set in the paint.
void android.graphics.Paint.setAntiAlias(boolean aa)
释义:
- Helper for setFlags(), setting or clearing the ANTI_ALIAS_FLAG bit AntiAliasing(反图像失真、反锯齿现象) smooths out the edges of what is being drawn, but is has no impact on(对...产生影响) the interior(内部、内在) of the shape.
参数:
- aa true to set the antialias bit in the flags, false to clear it
void CandidateView.setService(SoftKeyboard listener)
释义:
- A connection back to the service to communicate with the text field
参数:
- listener
int CandidateView.computeHorizontalScrollRange()
释义:
- 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.
Overrides(重写):
- computeHorizontalScrollRange() in View
返回:
- the total horizontal range represented by the horizontal scrollbar
void CandidateView.onMeasure(int widthMeasureSpec, int heightMeasureSpec)
释义:
- Measure the view and its content to determine the measured width and the measured height.
- This method is invoked by measure(int, int) and should be overriden by subclasses to provide accurate and efficient measurement of their contents.
合约:
- When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view.
- Failure to do so will trigger an IllegalStateException, thrown by measure(int, int).
- Calling the superclass' onMeasure(int, int) is a valid(合法的、有效的) use.
- The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec.
- Subclasses should override onMeasure(int, int) to provide better measurements of their content.
- If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).
重写:
- onMeasure(...) in View
参数:
- widthMeasureSpec horizontal space requirements as imposed by the parent.
- heightMeasureSpec vertical space requirements as imposed by the parent.
void android.view.View.requestLayout()
释义:
- Call this when something has changed which has invalidated the layout of this view.
- This will schedule a layout pass of the view tree.
void CandidateView.onDraw(Canvas canvas)
释义:
- If the canvas is null, then only touch calculations are performed to pick the target candidate.
重写:
- onDraw(...) in View
参数:
- canvas the canvas on which the background will be drawn
void android.graphics.Canvas.translate(float dx, float dy)
释义:
- Preconcat the current matrix(矩阵、基地) with the specified translation
参数:
- dx The distance to translate in X
- dy The distance to translate in Y