How to Highlight this pdf page using Ontouchevent in android

这里我想在android中使用onTouchevent突出显示此文本


You could use OnTouchListener to get the x and y of the event. Then drawing the screen to a bitmap and using bitmap.getPixel based on the top left display of the letter nd the size of your letters, to see if the next letter(s) next to it are also not spaces.Finally, put a yellow rectangle in between the white and the black lettering or the ones you wish to have highlighted.


You have to implement the onTouchListener for the button or any view you want. as like below:

implement the OnTouchListener:

public class DrawingActivity extends Activity implements View.OnTouchListener

Then implement the code for view touch action:

 public boolean onTouch(View view, MotionEvent motionEvent) {

    if(motionEvent.getAction() == MotionEvent.ACTION_DOWN){

    }else if(motionEvent.getAction() == MotionEvent.ACTION_MOVE){

    }else if(motionEvent.getAction() == MotionEvent.ACTION_UP){


    }

    return true;
}

Now add the code to open the pdf in to respective action. See this Example for the open pdf:

File file = new File("/sdcard/YOUR_PDF_FILE_PATH_WITH_NAME.pdf"); // give the path of your pdf file
                Uri path = Uri.fromFile(file);
                Intent intentPDF = new Intent(Intent.ACTION_VIEW);                     
                intentPDF.setDataAndType(path, "application/pdf");                     
                intentPDF.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);                      
                try {                         
                    startActivity(intentPDF);                     
                }                      
                catch (ActivityNotFoundException e) {                         
                    Toast.makeText(ListSample.this,                              
                         "No Application Available to View PDF",                              
                         Toast.LENGTH_SHORT).show();                     
                }       

Hope it will helps you. If not then let me know.

链接地址: http://www.djcxy.com/p/10418.html

上一篇: Android adb over Wifi安装apk

下一篇: 如何在Android中使用Ontouchevent突出显示此pdf页面