Android:如何在同一屏幕上制作Surface View和按钮?

时间:2012-05-20 18:49:29

标签: android image-processing ocr tesseract

到目前为止我所拥有的是两个类,第一个是一个简单的“欢迎页面”,主页面上有一个输入按钮,当用户点击时,第二个类显示一个表面视图和一个捕获按钮一张照片。到目前为止我做的是按照“marakana.com/forums/android/examples/39.html”中的步骤进行的。这一切都很好地显示表面视图和捕获图片但现在问题是我想使用OCR从捕获的图片中提取文本。我正在考虑使用“TESSERACT”并按照“http://www.itwizard.ro/interfacing-cc-libraries-via-jni-example-tesseract-163.html”中的步骤进行操作; ??欢迎任何建议?谢谢+我是Android和编程的新手。

1 个答案:

答案 0 :(得分:0)

尝试在ImageButton中使用叠加层。 创建新的Android XML布局文件,例如overlay.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal" >
  <ImageButton 
      android:id="@+id/bTake"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:src="@drawable/ic_menu_snap" android:layout_gravity="bottom"/>

要在主代码中创建叠加层,请使用LayoutInflater。

    LayoutInflater inflater = LayoutInflater.from(getBaseContext());
    View overlay = inflater.inflate(R.layout.overlay, null);
    LayoutParams params = new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
    addContentView(overlay, params);
    shotBtn = (ImageButton) overlay.findViewById(R.id.bTake);