我的應用程序有一個要求,用戶可以在屏幕上書寫他們的簽名。簽名應該能夠被提取到圖像中。在觸摸屏上捕獲文字
我應該怎麼辦?
是否有一個現有的Android進程/觀察員爲此?或者他們是否有可能允許功能的庫/插件?
我的應用程序有一個要求,用戶可以在屏幕上書寫他們的簽名。簽名應該能夠被提取到圖像中。在觸摸屏上捕獲文字
我應該怎麼辦?
是否有一個現有的Android進程/觀察員爲此?或者他們是否有可能允許功能的庫/插件?
使用此代碼在活動時間:
try {
GestureOverlayView gestureView = (GestureOverlayView) findViewById(R.id.signaturePad);
gestureView.setDrawingCacheEnabled(true);
Bitmap bm = Bitmap.createBitmap(gestureView.getDrawingCache());
File f = new File(Environment.getExternalStorageDirectory()+ File.separator + "signature.png");
f.createNewFile();
FileOutputStream os = new FileOutputStream(f);
os = new FileOutputStream(f);
//compress to specified format (PNG), quality - which is ignored for PNG, and out stream
bm.compress(Bitmap.CompressFormat.PNG, 100, os);
os.close();
} catch (Exception e) {
Log.v("Gestures", e.getMessage());
e.printStackTrace();
}
}
在XML:
<android.gesture.GestureOverlayView
android:id="@+id/signaturePad"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="5"
android:background="@android:color/white"
android:eventsInterceptionEnabled="true"
android:fadeEnabled="false"
android:gestureColor="@android:color/black"
android:gestureStrokeLengthThreshold="0.1"
android:gestureStrokeType="multiple"
android:orientation="vertical"/>
謝謝,應該給它一個鏡頭。問:應用程序何時知道何時創建位圖? –
在視圖上有簽名後調用上面的代碼。 –
嗯。謝謝。給它一個鏡頭。 –
使用手勢... –
謝謝,考慮看看。 –