1

android-zoom-view ( https://code.google.com/p/android-zoom-view/ )を実装したいです。ビルドパスにjarを追加しました。次のxmlを作成しました。

<?xml version="1.0" encoding="utf-8"?>
<pl.polidea.view.ZoomView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >

     <ImageView
        android:id="@+id/webcam1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_marginBottom="20dp"
        android:scaleType="matrix" />

    <ImageView
        android:id="@+id/webcam2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:scaleType="matrix" />
</pl.polidea.view.ZoomView>

次のコードをアクティビティに追加しました。

    View v = ((LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.zoomable_view, null, false);
    v.setLayoutParams(new LinearLayout.LayoutParams(
            LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));

    zoomView = new ZoomView(this);
    zoomView.addView(v);

    LinearLayout main_container = (LinearLayout) findViewById(R.id.LinearLayout1);
    main_container.addView(zoomView);

私は何を間違っていますか?次のエラーが表示されます。

Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class pl.polidea.view.ZoomView
4

2 に答える 2

5

次のコンストラクターを ZoomView クラスに追加したところ、ズームビューの少なくとも 1 つのイメージビューで機能するようになりました。

public ZoomView(final Context context, AttributeSet attr) {
     super(context, attr);     
}
于 2014-04-04T08:13:50.400 に答える