android输入法01:SoftKeyboard源码解析02

 本篇为SoftKeyboard源代码注释。

1、LatinKeyboard

[java]  view plain copy
  1. public class LatinKeyboard extends Keyboard {  
  2.   
  3.     private Key mEnterKey;  
  4.       
  5.     public LatinKeyboard(Context context, int xmlLayoutResId) {  
  6.         super(context, xmlLayoutResId);  
  7.         Log.i("mytest""LatinKeyboard_LatinKeyboard");  
  8.     }  
  9.   
  10.     public LatinKeyboard(Context context, int layoutTemplateResId,   
  11.             CharSequence characters, int columns, int horizontalPadding) {  
  12.         super(context, layoutTemplateResId, characters, columns, horizontalPadding);  
  13.         Log.i("mytest""LatinKeyboard_LatinKeyboard");  
  14.     }  
  15.   
  16.     /* 
  17.      * 描绘键盘时候(由构造函数 )自动调用 
  18.      * */  
  19.     @Override  
  20.     protected Key createKeyFromXml(Resources res, Row parent, int x, int y,   
  21.             XmlResourceParser parser) {  
  22.         Log.i("mytest""LatinKeyboard_createKeyFromXml");  
  23.         Key key = new LatinKey(res, parent, x, y, parser);  
  24.         //重载的目的,好像仅仅是为了记录回车键的值而已(以Key型记录)  
  25.         //无非就是想对回车键做改观  
  26.         if (key.codes[0] == 10) {  
  27.             mEnterKey = key;  
  28.         }  
  29.         return key;  
  30.     }  
  31.       
  32.     /** 
  33.      * This looks at the ime options given by the current editor, to set the 
  34.      * appropriate label on the keyboard's enter key (if it has one). 
  35.      */  
  36.     void setImeOptions(Resources res, int options) {  
  37.         //在SoftKeyboard的StartInput函数最后用到了  
  38.         //传入了EditorInfo.imeOptions类型的options参数。此变量地位与EditorInfo.inputType类似。但作用截然不同  
  39.         Log.i("mytest""LatinKeyboard_setImeOptions");  
  40.         if (mEnterKey == null) {  
  41.             return;  
  42.         }  
  43.       //惊爆:只要加载了EditorInfo的包,就可以使用其中的常量,所熟知的TextView类中的常量,经过试验也是可以任意使用的,猜测这些都是静态变量  
  44.         switch (options&(EditorInfo.IME_MASK_ACTION|EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {  
  45.             case EditorInfo.IME_ACTION_GO:  
  46.                 mEnterKey.iconPreview = null;  
  47.                 mEnterKey.icon = null;//把图片设为空,并不代表就是空,只是下面的Lable可以代替之  
  48.                 mEnterKey.label = res.getText(R.string.label_go_key);  
  49.                 break;  
  50.             case EditorInfo.IME_ACTION_NEXT:  
  51.                 mEnterKey.iconPreview = null;  
  52.                 mEnterKey.icon = null;  
  53.                 mEnterKey.label = res.getText(R.string.label_next_key);  
  54.                 break;  
  55.             case EditorInfo.IME_ACTION_SEARCH:  
  56.                 mEnterKey.icon = res.getDrawable(  
  57.                         R.drawable.sym_keyboard_search);  
  58.                 mEnterKey.label = null;  
  59.                 break;  
  60.             case EditorInfo.IME_ACTION_SEND:  
  61.                 mEnterKey.iconPreview = null;  
  62.                 mEnterKey.icon = null;  
  63.                 mEnterKey.label = res.getText(R.string.label_send_key);  
  64.                 break;  
  65.             default:  
  66.                 mEnterKey.icon = res.getDrawable(  
  67.                         R.drawable.sym_keyboard_return);  
  68.                 mEnterKey.label = null;  
  69.                 break;  
  70.         }  
  71.     }  
  72.        
  73.     static class LatinKey extends Keyboard.Key {  
  74.           
  75.         public LatinKey(Resources res, Keyboard.Row parent, int x, int y, XmlResourceParser parser) {  
  76.             super(res, parent, x, y, parser);  
  77.             Log.i("mytest""LatinKeyboard_LatinKey");  
  78.         }  
  79.           
  80.         /** 
  81.          * Overriding this method so that we can reduce the target area for the key that 
  82.          * closes the keyboard.  
  83.          */  
  84.         @Override  
  85.         public boolean isInside(int x, int y) {  
  86.             Log.i("mytest""LatinKeyboard_isInside");  
  87.             return super.isInside(x, codes[0] == KEYCODE_CANCEL ? y - 10 : y);  
  88.           //只有一个左下角cancel键跟super的此函数不一样,其余相同  
  89.           //仅仅为了防止错误的点击?将cancel键的作用范围减小了10,其余的,如果作用到位,都返回true  
  90.         }  
  91.     }  
  92.   
  93. }  
2、LatinKeyboardView

[java]  view plain copy
  1. public class LatinKeyboardView extends KeyboardView {  
  2.   
  3.     //网上说:当继承View的时候,会有个一个含有AttributeSet参数的构造方法,  
  4.     //通过此类就可以得到自己定义的xml属性,也可以是android的内置的属性  
  5.     //就好像TextView这东西也有个 View的基类  
  6.       
  7.     //干什么用的?好像是设了一个无用的键值,等到后面调用  
  8.     static final int KEYCODE_OPTIONS = -100;  
  9.   
  10.     public LatinKeyboardView(Context context, AttributeSet attrs) {  
  11.         super(context, attrs);  
  12.         Log.i("mytest""LatinKeyboardView_LatinKeyboardView(Context context, AttributeSet attrs) ");  
  13.     }  
  14.   
  15.     public LatinKeyboardView(Context context, AttributeSet attrs, int defStyle) {  
  16.         super(context, attrs, defStyle);  
  17.         Log.i("mytest""LatinKeyboardView_LatinKeyboardView(Context context, AttributeSet attrs, int defStyle)");  
  18.     }  
  19.   
  20.     @Override  
  21.     protected boolean onLongPress(Key key) {  
  22.         Log.i("mytest""LatinKeyboardView_onLongPress");  
  23.         //codes[0]代表当前按的值.按时间长了就失去了效果(cancel)  
  24.         if (key.codes[0] == Keyboard.KEYCODE_CANCEL) {  
  25.             getOnKeyboardActionListener().onKey(KEYCODE_OPTIONS, null);  
  26.             return true;  
  27.         } else {  
  28.             return super.onLongPress(key);  
  29.         }  
  30.     }  
  31. }  
3、CandidateView

[java]  view plain copy
  1. public class CandidateView extends View {  
  2.   
  3.     private static final int OUT_OF_BOUNDS = -1;  
  4.   
  5.     //这个是这个candidateView的宿主类,也就是该view是为什么输入法服务的。  
  6.     private SoftKeyboard mService;  
  7.   //这个是建议。比如说当我们输入一些字母之后输入法希望根据输入来进行联想建议。  
  8.     private List<String> mSuggestions;  
  9.   //这个是用户选择的词的索引。  
  10.     private int mSelectedIndex;  
  11.     private int mTouchX = OUT_OF_BOUNDS;  
  12.       
  13.     //这个是用来描绘选择区域高亮的一个类  
  14.     private Drawable mSelectionHighlight;  
  15.     //键入的word是否合法正确。  
  16.     private boolean mTypedWordValid;  
  17.       
  18.     //背景填充区域,决定将要在那个部分显示?  
  19.     private Rect mBgPadding;  
  20.   
  21.     private static final int MAX_SUGGESTIONS = 32;  
  22.     private static final int SCROLL_PIXELS = 20;  
  23.       
  24.     //这个是对于候选词的每个词的宽度  
  25.     private int[] mWordWidth = new int[MAX_SUGGESTIONS];  
  26.     //这个是每个候选词的X坐标。  
  27.     private int[] mWordX = new int[MAX_SUGGESTIONS];  
  28.   
  29.     //难道是两个词语之间的间隙?对了!  
  30.     private static final int X_GAP = 10;  
  31.       
  32.     private static final List<String> EMPTY_LIST = new ArrayList<String>();  
  33.   
  34.     private int mColorNormal;  
  35.     private int mColorRecommended;  
  36.     private int mColorOther;  
  37.     private int mVerticalPadding;  
  38.       
  39.     //所有关于绘制的信息,比如线条的颜色等  
  40.     private Paint mPaint;  
  41.     private boolean mScrolled;  
  42.     private int mTargetScrollX;  
  43.       
  44.     private int mTotalWidth;  
  45.       
  46.     private GestureDetector mGestureDetector;  
  47.   
  48.     /** 
  49.      * Construct a CandidateView for showing suggested words for completion. 
  50.      * @param context 
  51.      * @param attrs 
  52.      */  
  53.     public CandidateView(Context context) {  
  54.         //activity,inputmethodservice,这都是context的派生类  
  55.         super(context);  
  56.       //getResouces这个函数用来得到这个应用程序的所有资源,就连android自带的资源也要如此  
  57.         mSelectionHighlight = context.getResources().getDrawable(  
  58.                 android.R.drawable.list_selector_background);  
  59.       //mSelectionHighlight类型是Drawable,而Drawable设置状态就是这样  
  60.         mSelectionHighlight.setState(new int[] {  
  61.                 android.R.attr.state_enabled,  //这行如果去掉,点击候选词的时候是灰色,但是也可以用  
  62.                 android.R.attr.state_focused, //用处不明。。。。  
  63.                 android.R.attr.state_window_focused, //这行如果去掉,当点击候选词的时候背景不会变成橙色  
  64.                 android.R.attr.state_pressed //点击候选词语时候背景颜色深浅的变化,不知深层意义是什么?  
  65.         });  
  66.   
  67.         Resources r = context.getResources();  
  68.           
  69.         setBackgroundColor(r.getColor(R.color.candidate_background));  
  70.       //设置高亮区域的背景颜色,还是透明的,很美,很美,但为什么是透明的还有待考证?  
  71.           
  72.       //这个颜色,是非首选词的颜色  
  73.         mColorNormal = r.getColor(R.color.candidate_normal);  
  74.       //找到了,这个是显示字体的颜色  
  75.         mColorRecommended = r.getColor(R.color.candidate_recommended);  
  76.       //这个是候选词语分割线的颜色  
  77.         mColorOther = r.getColor(R.color.candidate_other);  
  78.           
  79.       //这是系统定义的一个整型变量。用就可以了  
  80.         mVerticalPadding = r.getDimensionPixelSize(R.dimen.candidate_vertical_padding);  
  81.           
  82.         mPaint = new Paint();  
  83.         mPaint.setColor(mColorNormal);  
  84.       //这行如果没有,那么字体的线条就不一样  
  85.         mPaint.setAntiAlias(true);  
  86.         mPaint.setTextSize(r.getDimensionPixelSize(R.dimen.candidate_font_height));  
  87.         mPaint.setStrokeWidth(0);  
  88.           
  89.       //用手可以滑动,这是在构造函数里面对滑动监听的重载,猜测,这个函数与onTouchEvent函数应该是同时起作用?  
  90.         mGestureDetector = new GestureDetector(new GestureDetector.SimpleOnGestureListener() {  
  91.             @Override  
  92.             public boolean onScroll(MotionEvent e1, MotionEvent e2,  
  93.                     float distanceX, float distanceY) {  
  94.                 mScrolled = true;  
  95.               //得到滑动开始的横坐标  
  96.                 int sx = getScrollX();  
  97.                 //加上滑动的距离,这个滑动距离是最后一次call滑动之间的距离,很小,应该  
  98.                 sx += distanceX;  
  99.                 if (sx < 0) {  
  100.                     sx = 0;  
  101.                 }  
  102.                 if (sx + getWidth() > mTotalWidth) {                      
  103.                     sx -= distanceX;  
  104.                 }  
  105.                 //记录将要移动到的位置,后面会用到  
  106.                 mTargetScrollX = sx;  
  107.                 //这是处理滑动的函数,view类的函数。后面一个参数,说明Y轴永远不变,如果你尝试去改变一下,经测试,太好玩了  
  108.                 scrollTo(sx, getScrollY());  
  109.                 //文档中说的是使得整个VIew作废,但是如果不用这句,会发生什么?  
  110.                 invalidate();  
  111.                 return true;  
  112.             }  
  113.         });  
  114.       //这后三行语句不是在GestureDetector函数中的,而是在构造函数中的,当候选View建立成功的时候就已经是下面的状态了  
  115.       //拖动时刻左右两边的淡出效果  
  116.         setHorizontalFadingEdgeEnabled(true);  
  117.       //当拖动的时候,依旧可以输入并显示  
  118.         setWillNotDraw(false);  
  119.           
  120.       //作用暂时不明?  
  121.         setHorizontalScrollBarEnabled(false);  
  122.         setVerticalScrollBarEnabled(false);  
  123.         Log.i("mytest""CandidateView_CandidateView");  
  124.     }  
  125.       
  126.     /** 
  127.      * A connection back to the service to communicate with the text field 
  128.      * @param listener 
  129.      */  
  130.     public void setService(SoftKeyboard listener) {  
  131.         //自己定义的废柴函数,使得私有变量mService的值得以改变  
  132.         mService = listener;  
  133.         Log.i("mytest""CandidateView_setService");  
  134.     }  
  135.       
  136.     @Override  
  137.     public int computeHorizontalScrollRange() {  
  138.         Log.i("mytest""CandidateView_computeHorizontalScrollRange");  
  139.         return mTotalWidth;  
  140.           
  141.     }  
  142.   
  143.     @Override  
  144.     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {  
  145.         //猜测:如果第二参数是从onMeasure的参数中来的,就用第二变量  
  146.         //这个函数是个调和宽度函数,一般情况下用参数1值,除非第二个参数给其限制  
  147.         int measuredWidth = resolveSize(50, widthMeasureSpec);  
  148.         Log.i("mytest""CandidateView_onMeasure");  
  149.         // Get the desired height of the icon menu view (last row of items does  
  150.         // not have a divider below)  
  151.         Rect padding = new Rect();  
  152.       //吴:高亮区域除了字以外,剩下的空隙,用getPadding得到,或许,这是由list_selector_background决定的。  
  153.         mSelectionHighlight.getPadding(padding);  
  154.         final int desiredHeight = ((int)mPaint.getTextSize()) + mVerticalPadding  
  155.                 + padding.top + padding.bottom;  
  156.           
  157.         // Maximum possible width and desired height  
  158.         setMeasuredDimension(measuredWidth,  
  159.                 resolveSize(desiredHeight, heightMeasureSpec));  
  160.           
  161.     }  
  162.   
  163.     /** 
  164.      * If the canvas is null, then only touch calculations are performed to pick the target 
  165.      * candidate. 
  166.      */  
  167.     @Override  
  168.     protected void onDraw(Canvas canvas) {  
  169.         //这是每个View对象绘制自己的函数,重载之。经测试:没有这个函数的重载,则显示不出字来,这个就是用来显示字条  
  170.         Log.i("mytest""CandidateView_onDraw");  
  171.         if (canvas != null) {  
  172.             super.onDraw(canvas);  
  173.         }  
  174.         mTotalWidth = 0;  
  175.         if (mSuggestions == nullreturn;  
  176.           
  177.         if (mBgPadding == null) {  
  178.             mBgPadding = new Rect(0000);  
  179.             if (getBackground() != null) {  
  180.                 getBackground().getPadding(mBgPadding);  
  181.             }  
  182.         }  
  183.         //第一个词左侧为0,测试知道:这个地方能改变文字的左侧开端  
  184.         int x = 0;  
  185.         final int count = mSuggestions.size();   
  186.         final int height = getHeight();  
  187.         final Rect bgPadding = mBgPadding;  
  188.         final Paint paint = mPaint;  
  189.         final int touchX = mTouchX;  //取得被点击词语的横坐标  
  190.         final int scrollX = getScrollX();  
  191.         final boolean scrolled = mScrolled;  
  192.         final boolean typedWordValid = mTypedWordValid;  
  193.         final int y = (int) (((height - mPaint.getTextSize()) / 2) - mPaint.ascent());  
  194.   
  195.         for (int i = 0; i < count; i++) { //开始一个一个地添置候选词,但是本例中,候选词只能有1个?  
  196.             String suggestion = mSuggestions.get(i);  
  197.           //获取词语宽度,但是词语的字号又是怎么设定的呢?  
  198.             float textWidth = paint.measureText(suggestion);  
  199.           //整体宽度是词语宽度加上两倍间隙  
  200.             final int wordWidth = (int) textWidth + X_GAP * 2;  
  201.   
  202.             mWordX[i] = x;  
  203.             mWordWidth[i] = wordWidth;  
  204.             paint.setColor(mColorNormal);  
  205.           //保持正常输出而不受触摸影响的复杂条件  
  206.             if (touchX + scrollX >= x && touchX + scrollX < x + wordWidth && !scrolled) {  
  207.                 if (canvas != null) {  
  208.                      //画布转变位置,按下候选词后,看到的黄色区域是画布处理的位置  
  209.                     canvas.translate(x, 0);  
  210.                     mSelectionHighlight.setBounds(0, bgPadding.top, wordWidth, height);  
  211.                     mSelectionHighlight.draw(canvas);  
  212.                   //上面两句是密不可分的,第一步给框,第二步画画,不知与canvas.translate(x, 0);什么关系。画布与词的显示位置好像没有什么关系  
  213.                   //词的位置的改变在下面处理  
  214.                     canvas.translate(-x, 0);  
  215.                 }  
  216.                 mSelectedIndex = i;  
  217.             }  
  218.   
  219.             if (canvas != null) {  
  220.                 if ((i == 1 && !typedWordValid) || (i == 0 && typedWordValid)) {  
  221.                      //第一个候选词,设置不同的显示式样,粗体  
  222.                     paint.setFakeBoldText(true);  
  223.                     paint.setColor(mColorRecommended);  
  224.                 } else if (i != 0) {  
  225.                     paint.setColor(mColorOther);  
  226.                 }  
  227.               //测试得:这里才能决定词语出现的位置  
  228.                 canvas.drawText(suggestion, x + X_GAP, y, paint);  
  229.                 paint.setColor(mColorOther);   
  230.                 canvas.drawLine(x + wordWidth + 0.5f, bgPadding.top,   
  231.                         x + wordWidth + 0.5f, height + 1, paint);  
  232.                 paint.setFakeBoldText(false);  
  233.             }  
  234.             x += wordWidth;  
  235.         }  
  236.         mTotalWidth = x;  
  237.         //每个滑动,都会造成mTargetScrollX改变,因为他在动作监听函数里面赋值  
  238.         if (mTargetScrollX != getScrollX()) {  
  239.             //意思是说:只要移动了。难道是说如果在移动完成之后进行的输入,则进行下面操作?  
  240.             //如果在移动完成之后输入,那么mTargetScrollX记录的也是移动最终目标的水平坐标  
  241.             scrollToTarget();  
  242.         }  
  243.           
  244.     }  
  245.   //这个地方,应该和下面的setSuggestions函数一起看,对于滑动之后一输入就归零的问题,有两个原因,源头  
  246.   //都在setSuggestions函数中,一个是scrollTo(0, 0);这句话,每当输入一个字母,就有了一个新词语,这个新词语  
  247.   //会致使scrollTo(0, 0);的发生。但是就算把这句话注释掉,下面的一句mTargetScrollX = 0;也会使得Ondraw()  
  248.   //这个函数的调用到最后的时候,执行scrollToTarget();产生作用,回复到0位置。  
  249.     private void scrollToTarget() {  
  250.         Log.i("mytest""CandidateView_scrollToTarget");  
  251.         int sx = getScrollX();  
  252.         if (mTargetScrollX > sx) {  
  253.             sx += SCROLL_PIXELS;  
  254.             if (sx >= mTargetScrollX) {  
  255.                 sx = mTargetScrollX;  
  256.                 requestLayout();  
  257.             }  
  258.         } else {  
  259.             sx -= SCROLL_PIXELS;  
  260.             if (sx <= mTargetScrollX) {  
  261.                 sx = mTargetScrollX;  
  262.                 requestLayout();  
  263.             }  
  264.         }  
  265.         //移动之  。 p.s不要把高亮区与候选栏相混,移动的,是候选栏,高亮区自从生成就亘古不变,直到消失  
  266.         scrollTo(sx, getScrollY());  
  267.         invalidate();  
  268.     }  
  269.       
  270.     public void setSuggestions(List<String> suggestions, boolean completions,  
  271.             boolean typedWordValid) {  
  272.         //此函数本类中出现就一次,会在别的类中调用,没有内部调用  
  273.         Log.i("mytest""CandidateView_setSuggestions");  
  274.         clear();  
  275.         if (suggestions != null) {  
  276.               //新的建议集合字串就是传过来的这个参数字串。  
  277.             mSuggestions = new ArrayList<String>(suggestions);  
  278.         }  
  279.       //确定此词是否可用?  
  280.         mTypedWordValid = typedWordValid;  
  281.       //每当有新的候选词出现,view就会滑动到初始的位置  
  282.         scrollTo(00);  
  283.         mTargetScrollX = 0;  
  284.         // Compute the total width  
  285.       //onDraw的参数为null的时候,他不再执行super里面的onDraw  
  286.         onDraw(null);  
  287.         invalidate();  
  288.         requestLayout();//文档:当View作废时候使用  
  289.     }  
  290.   
  291.     public void clear() {  
  292.         Log.i("mytest""CandidateView_clear");  
  293.         //前面定义了,这是一个空数组,将候选词库弄为空数组  
  294.         mSuggestions = EMPTY_LIST;  
  295.         mTouchX = OUT_OF_BOUNDS;  
  296.       //把被触摸的横坐标定为一个负数,这样的话就等于没触摸  
  297.         mSelectedIndex = -1;  
  298.         invalidate();  
  299.     }  
  300.       
  301.     @Override  
  302.     public boolean onTouchEvent(MotionEvent me) {  
  303.         //这是触屏选词工作  
  304.         Log.i("mytest""CandidateView_onTouchEvent");  
  305.           //猜测,如果前面那个滑动监听函数起了作用,就不用再乎这个函数后面的了,这是对的!  
  306.         //文档中这样解释:GestureDetector.OnGestureListener使用的时候,这里会返回  
  307.         //true,后面又说,前面定义的GestureDetector.SimpleOnGestureListener,  
  308.         //是GestureDetector.OnGestureListener的派生类  
  309.         if (mGestureDetector.onTouchEvent(me)) {  
  310.             return true;  
  311.         }//p.s.经注解忽略测试发现:所有的触摸效果源自这里。如果注解掉,则不会发生滑动  
  312.   
  313.         int action = me.getAction();  
  314.         int x = (int) me.getX();  
  315.         int y = (int) me.getY();  
  316.         mTouchX = x;  //被点击词语的横坐标  
  317.   
  318.         //如果后续出现滑动,又会被前面那个监听到的  
  319.         switch (action) {  
  320.         case MotionEvent.ACTION_DOWN:  
  321.             mScrolled = false;  
  322.             invalidate();  
  323.             break;  
  324.         case MotionEvent.ACTION_MOVE:  
  325.             //选词,经过测试,当向上滑动的时候也是可以选词的  
  326.             if (y <= 0) {  
  327.                 // Fling up!?  
  328.                 if (mSelectedIndex >= 0) {  
  329.                     mService.pickSuggestionManually(mSelectedIndex);  
  330.                     mSelectedIndex = -1;  
  331.                 }  
  332.             }  
  333.             invalidate();  
  334.             break;  
  335.         case MotionEvent.ACTION_UP:  
  336.             if (!mScrolled) {  
  337.                 if (mSelectedIndex >= 0) {  
  338.                     mService.pickSuggestionManually(mSelectedIndex); //点击选词经测试合格  
  339.                 }  
  340.             }  
  341.             mSelectedIndex = -1;  
  342.             removeHighlight();//消除高亮区域  
  343.             requestLayout();  //文档:当View作废时候使用  
  344.             break;  
  345.         }  
  346.         return true;  
  347.     }  
  348.       
  349.     /** 
  350.      * For flick through from keyboard, call this method with the x coordinate of the flick  
  351.      * gesture. 
  352.      * @param x 
  353.      */  
  354.     public void takeSuggestionAt(float x) {  
  355.         //本类中只出现了一次,在别的类中有调用  
  356.         Log.i("mytest""CandidateView_takeSuggestionAt");  
  357.           //此处也给mTouchX赋了非负值  
  358.         mTouchX = (int) x;  
  359.         // To detect candidate  
  360.         onDraw(null);  
  361.         if (mSelectedIndex >= 0) {  
  362.             mService.pickSuggestionManually(mSelectedIndex);  
  363.         }  
  364.         invalidate();  
  365.     }  
  366.   
  367.     private void removeHighlight() {//取消高亮区域的显示,等待下次生成  
  368.         Log.i("mytest""CandidateView_removeHighlight");  
  369.           //把被触摸的横坐标定为一个负数,这样的话就等于没触摸  
  370.         mTouchX = OUT_OF_BOUNDS;  
  371.         invalidate();  
  372.     }  
  373. }  

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值