Zxings barcannerアプリ、これをライブラリプロジェクトとして実装しています。ZXings barcodescannerにメニューを追加し、サーフェイスビューを絞る
ここでは、スキャンされたフィールド(ターゲットフィールド)のサイズを変更します(同様に行われます)。 (スキャンエリアは同じままですが、フォーカスがまだ中央にあるのでこれは問題ではありません)。しかし、左側のメニューを挿入する必要がありました。これにより、Target Fieldを変更する必要があります。これは、surfaceviewまたはviewFinderViewのサイズを変更して相対ビューでラップしても、(原因の)中心だけをデコードする場合にクラッシュします。私はちょうど解決策を見つけることができません: -/
短い:私はスキャンが起こっている必要がありますが、これは表示される領域を変更することができます。実際のスキャン領域は、まだ完全な画面の中心であり、移動した可視スキャン領域の中心ではありません。
誰でも手伝ってもらえますか?
レイアウトXML(削除挿入メニュー、および不要で):
<SurfaceView
android:id="@+id/preview_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<com.google.zxing.client.android.ViewfinderView
android:layout_marginLeft="120dip"
android:id="@+id/viewfinder_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/transparent" />
<LinearLayout
android:id="@+id/buttonPanel"
android:layout_width="120dip"
android:layout_height="fill_parent"
android:background="#000"
android:orientation="vertical"
android:paddingBottom="15dip"
android:paddingTop="15dip" >
<TextView
android:id="@+id/menuText"
android:layout_weight="1"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:text="@string/menu_title"/>
<ImageView
android:id="@+id/d1Button"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_weight="2"
android:onClick="scanner1d"
android:src="@drawable/d1image" />
<ImageView
android:id="@+id/d2Button"
android:layout_width="90dip"
android:layout_height="wrap_content"
android:layout_marginLeft="15dip"
android:layout_weight="2"
android:onClick="scanner2d"
android:src="@drawable/d2image" />
</LinearLayout>
<LinearLayout
android:id="@+id/result_view"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/result_view"
android:orientation="vertical"
android:padding="4dip"
android:visibility="gone" >
**removed**
</LinearLayout>
**removed**
左画像:ビューは今であり、それが認識されていない場合にアイテムを配置する方法です。
右画像:それは認識されているアイテムの配置(私はその対象領域が変更されていないチェック方法):CameraManager(ビューファインダーの絞り)へ
変更:
public Rect getFramingRect() {
// added
int menuSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,
(float) 120, context.getResources().getDisplayMetrics());
// end of added
Point screenResolution = configManager.getScreenResolution();
if (framingRect == null) {
if (camera == null) {
return null;
}
int width = screenResolution.x * 3/4;
if (width < MIN_FRAME_WIDTH) {
width = MIN_FRAME_WIDTH;
} else if (width > MAX_FRAME_WIDTH) {
width = MAX_FRAME_WIDTH;
}
int height = screenResolution.y * 3/4;
if (height < MIN_FRAME_HEIGHT) {
height = MIN_FRAME_HEIGHT;
} else if (height > MAX_FRAME_HEIGHT) {
height = MAX_FRAME_HEIGHT;
}
// added menu size for calculation
int leftOffset = ((screenResolution.x -menuSize - width)/2);
int topOffset = (screenResolution.y - height)/2;
framingRect = new Rect(leftOffset, topOffset, leftOffset + width,
topOffset + height);
Log.d(TAG, "Calculated framing rect: " + framingRect);
}
return framingRect;
}
今私は小さなプロジェクトに取り組んできました。 here(問題は修正され、libが欠けていました)oct 18 10:14 C ET
コードはそのままです。 –
スタックトレースを失い、それらを再作成します。まもなく彼らに説明を追加してください –
面白かったのがビューファインダービューだったのですが、同じサイズであれば "動作"していても大きな問題になりました。 –