一內(nèi)容:設(shè)計(jì)一個(gè)手寫(xiě)字體識(shí)別程序。
十余年的東方網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都營(yíng)銷(xiāo)網(wǎng)站建設(shè)的優(yōu)勢(shì)是能夠根據(jù)用戶(hù)設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整東方建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)公司從事“東方網(wǎng)站設(shè)計(jì)”,“東方網(wǎng)站推廣”以來(lái),每個(gè)客戶(hù)項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
二實(shí)現(xiàn)
①建立一個(gè)存放手寫(xiě)字體的數(shù)據(jù)庫(kù)
②activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Gesture:"
android:id="@+id/tv"
android:textSize="24dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20dp"
android:text="clear"
android:id="@+id/bt"/>
<android.gesture.GestureOverlayView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gestureStrokeType="multiple"
android:eventsInterceptionEnabled="false"
android:orientation="vertical"
android:id="@+id/gesture"></android.gesture.GestureOverlayView>
</LinearLayout
3.MainActivity.java
package com.example.myapplication;
import android.gesture.Gesture;
import android.gesture.GestureLibraries;
import android.gesture.GestureLibrary;
import android.gesture.GestureOverlayView;
import android.gesture.Prediction;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class MainActivity extends AppCompatActivity implements GestureOverlayView.OnGesturePerformedListener {
GestureLibrary mLibrary; //定義手勢(shì)庫(kù)對(duì)象
GestureOverlayView gest; //定義手勢(shì)視圖對(duì)象做畫(huà)板之用
TextView txt;
Button bt;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
gest = (GestureOverlayView)findViewById(R.id.gesture);
gest.addOnGesturePerformedListener(this); // 注冊(cè)手勢(shì)識(shí)別的監(jiān)聽(tīng)器
txt = (TextView)findViewById(R.id.tv);
mLibrary = GestureLibraries.fromRawResource(this,R.raw.gestures); //加載手勢(shì)庫(kù)
bt = (Button)findViewById(R.id.bt);
bt.setOnClickListener(new Click());
if (!mLibrary.load()) {
finish();
}
}
/*根據(jù)畫(huà)的手勢(shì)識(shí)別是否匹配手勢(shì)庫(kù)里的手勢(shì)*/
@Override
public void onGesturePerformed(GestureOverlayView gest, Gesture gesture) {
ArrayList gestList = mLibrary.recognize(gesture); // 從手勢(shì)庫(kù)獲取手勢(shì)數(shù)據(jù)
if (gestList.size() > 0) {
Prediction pred = (Prediction)gestList.get(0);
if (pred.score > 1.0) { // 檢索到匹配的手勢(shì)
Toast.makeText(this,pred.name,Toast.LENGTH_SHORT).show();
txt.append(pred.name);
}
}
}
private class Click implements View.OnClickListener {
@Override
public void onClick(View view) {
txt.setText("Gesture:");
}
}
}
三效果

以上所述是小編給大家介紹的AndroidStudio手勢(shì)識(shí)別詳解整合,希望對(duì)大家有所幫助,如果大家有任何疑問(wèn)請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)創(chuàng)新互聯(lián)網(wǎng)站的支持!
文章名稱(chēng):AndroidStudio:手勢(shì)識(shí)別
路徑分享:http://www.yijiale78.com/article30/pchcpo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、網(wǎng)站設(shè)計(jì)公司、網(wǎng)頁(yè)設(shè)計(jì)公司、ChatGPT、定制開(kāi)發(fā)、企業(yè)網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)