1

スタンドアロンにするために、アプリにzxingを完全に含めました。それは動作しますが、カメラは回転していて(私は反時計回りに90と思います)、奇妙なパディングがあります。私のJava:

package it.mi.action.codmmunicator_2ddecoder;

import android.os.Bundle;
import android.widget.Toast;
import android.graphics.Bitmap;
import com.google.zxing.Result;
import com.google.zxing.client.android.CaptureActivity;

public class Lettore extends CaptureActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.lettore);
}
@Override 
public void handleDecode(Result rawResult, Bitmap barcode) {
    Toast.makeText(this.getApplicationContext(), "Scanned code " +     rawResult.getText(), Toast.LENGTH_LONG);
}
}

そして私のxml(インクルードのようにzxingのアクティビティを取ります):

<?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="vertical">
<ImageView android:src="@drawable/head" android:layout_width="wrap_content"     android:layout_height="wrap_content" /> 
<FrameLayout android:layout_width="fill_parent" android:layout_height="250dip">
    <include layout="@layout/capture" android:toDegrees="90" />
</FrameLayout>
</LinearLayout>

パディングはこれです:https ://dl.dropbox.com/u/16047047/Untitled-1.jpg

誰かが解決策を投稿できますか?

どうもありがとう

4

2 に答える 2

2

Zxingは横向きのムード専用に設計されているため、90度回転しています..そして、あなたのアプリケーションは縦向きのムードで動作していると思います.

あなたはこれを試すことができますConfigurationManager.java

void setDesiredCameraParameters(Camera camera) {
    Camera.Parameters parameters = camera.getParameters();
    Log.d(TAG, "Setting preview size: " + cameraResolution);
    parameters.setPreviewSize(cameraResolution.x, cameraResolution.y);
    parameters.set("orientation", "portrait");
    parameters.setRotation(90);
    if (camera != null)
        try {
            camera.setDisplayOrientation(90);
        } catch (NoSuchMethodError ex) {
        }
    setFlash(parameters);
    setZoom(parameters);
    // setSharpness(parameters);
    setSharpness(parameters);
    camera.setParameters(parameters);

}

注: ただし、プロジェクトにコードを含める方法ではありません。インテントを通じて使用する必要があります。

于 2012-06-29T13:53:40.813 に答える
1

マニフェスト ファイルを横向きモードのみに変更するだけです。

<activity
        android:name="com.google.zxing.client.android.CaptureActivity"
        android:label="ZXing"
        android:screenOrientation="landscape"/>
于 2013-01-24T07:29:16.013 に答える