先日Android Studioを触り始めた初心者です。
Zxingを使用してQRコードの読込みをしています。
読込み画面の大きさを変更しようとしているのですが、カスタマイズした読込み画面が表示されません。
原因が不明なためご教授いただければ幸いです。
//ボタンクリックで読込み画面起動
@Override
public void onClick(View aView) {
switch (aView.getId()) {
// SCAN
case R.id.button_scan2:
IntentIntegrator integrator = new IntentIntegrator(ScanMainActivity1.this);
integrator.setCaptureActivity(SmallCaptureActivity.class);←カスタマイズ画面
// スキャンするバーコード形式を指定
integrator.setDesiredBarcodeFormats(IntentIntegrator.QR_CODE);
// キャプチャ画面起動
integrator.initiateScan();
break;
default:
break;
}
}
//カスタマイズ画面(SmallCaptureActivity.java) ※zxing-android-embedded-master
import com.journeyapps.barcodescanner.CaptureActivity;
import com.journeyapps.barcodescanner.DecoratedBarcodeView;
/**
- This activity has a margin.
*/
public class SmallCaptureActivity extends CaptureActivity {
@Override
protected DecoratedBarcodeView initializeContent() {
setContentView(R.layout.capture_small);
return (DecoratedBarcodeView)findViewById(R.id.zxing_barcode_scanner);
}
}
// capture_small.xml
<?xml version="1.0" encoding="UTF-8"?>// Copyright (C) 2008 ZXing authors -- 中略
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".SmallCaptureActivity">
</RelativeLayout><com.journeyapps.barcodescanner.DecoratedBarcodeView android:layout_alignParentLeft="true" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" android:layout_alignParentTop="true" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginLeft="50dp" android:layout_marginRight="50dp" android:layout_marginTop="150dp" android:layout_marginBottom="150dp" android:id="@+id/zxing_barcode_scanner" app:zxing_use_texture_view="false" app:zxing_preview_scaling_strategy="fitXY"/>
// app/build.gradeへの追加
repositories {
mavenCentral();
maven {
url "http://dl.bintray.com/journeyapps/maven"
}
maven {
url "https://raw.github.com/embarkmobile/zxing-android-minimal/mvn-repo/maven-repository/"
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test🏃♂️1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.journeyapps:zxing-android-embedded:3.6.0'
implementation 'com.google.zxing:core:3.3.2'
}
試したこと
・インターネット等での検索
・デザイン画面のパレットにデフォルトにないzxing_barcode_scannerをすることはNGなのでしょうか?
であればどうすればパレットにUIを追加できるのでしょうか?
補足情報(FW/ツールのバージョンなど)
・Wiondows 10 Pro 64bitOS
・javac 1.8.0_191
・Android Sudio 3.2.1
・Android Sudioにてプロキシの設定をしています。
AndroidManifest への追加
<activity android:name=".SubMainActivity1" />
<activity android:name=".ScanMainActivity1"></activity>
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。