这里我想在android
中使用onTouchevent来突出显示这个文本答案 0 :(得分:2)
您可以使用OnTouchListener获取事件的x和y。然后将屏幕绘制到位图并使用bitmap.getPixel基于字母的左上角显示和字母的大小,以查看它旁边的下一个字母是否也不是空格。最后,放一个黄色白色和黑色字母之间的矩形或您希望突出显示的矩形。
答案 1 :(得分:1)
您必须为按钮或所需的任何视图实现onTouchListener。 如下所示:
实现OnTouchListener:
public class DrawingActivity extends Activity implements View.OnTouchListener
然后实现视图触摸操作的代码:
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;
}
现在添加代码以打开pdf进入相应的操作。 有关打开的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();
}
希望它会对你有所帮助。如果没有,请告诉我。