0

私のapplication.iではRelativeLayoutを使用しました。イメージビューに横スクロールビューと縦スクロールビューを追加したい。私はそれを試しましたが、動作しません。イメージビューのサイズは 800*800 にする必要があります。LinearLayout が必要ですか。どうすればこれを行うことができますか?助けてください。

xml ファイル -

  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Beige"
android:focusable="true"
android:orientation="vertical" >

<LinearLayout
    android:id="@+id/linearLayout1"
    style="@color/Bisque"
    android:layout_width="250dp"
    android:layout_height="fill_parent"
    android:background="@color/Plum"
    android:orientation="vertical" >

    <Button
        android:id="@+id/button1"
        android:layout_width="60dp"
        android:layout_height="50dp"
        android:layout_marginLeft="20dp"
        android:layout_marginTop="30dp"
        android:background="@color/Thistle"
        android:onClick="importFile"
        android:text="@string/Import" />

    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="50dp"
        android:background="@color/Thistle"
        android:orientation="vertical" >
    </LinearLayout>

    <LinearLayout
        android:layout_width="200dp"
        android:layout_height="210dp"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="50dp"
        android:background="@color/Thistle"
        android:orientation="vertical" >

        <LinearLayout
            android:layout_width="180dp"
            android:layout_height="50dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/yes"
                android:layout_width="wrap_content"
                android:layout_height="40dp"
                android:layout_weight="0.15"
                android:background="@color/Thistle"
                android:focusable="false"
                android:text="@string/X"
                android:textColor="@color/PaleVioletRed"
                android:textColorHint="@color/PaleVioletRed"
                android:textSize="35sp"
                android:textStyle="bold"
                android:typeface="normal"
                android:width="4dp" />

            <Button
                android:id="@+id/no"
                android:layout_width="30dp"
                android:layout_height="40dp"
                android:layout_marginLeft="60dp"
                android:background="@drawable/cor" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="180dp"
            android:layout_height="50dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/back"
                android:layout_width="40dp"
                android:layout_height="30dp"
                android:layout_marginTop="5dp"
                android:background="@color/Thistle"
                android:text="@string/l"
                android:textColor="@color/PaleVioletRed"
                android:textColorHint="@color/PaleVioletRed"
                android:textSize="30sp"
                android:textStyle="bold"
                android:typeface="sans" />

            <TextView
                android:id="@+id/color"
                android:layout_width="40dp"
                android:layout_height="30dp"
                android:layout_marginLeft="10dp"
                android:background="@color/Black" />

            <Button
                android:id="@+id/next"
                android:layout_width="40dp"
                android:layout_height="30dp"
                android:layout_marginLeft="10dp"
                android:layout_marginTop="6dp"
                android:background="@color/Thistle"
                android:text="@string/r"
                android:textColor="@color/PaleVioletRed"
                android:textSize="30sp"
                android:textStyle="bold"
                android:typeface="sans" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="180dp"
            android:layout_height="50dp"
            android:layout_marginTop="20dp"
            android:gravity="center"
            android:orientation="horizontal" >

            <Button
                android:id="@+id/sub"
                android:layout_width="40dp"
                android:layout_height="30dp"
                android:background="@drawable/plus"
                android:textSize="40sp" />

            <Button
                android:id="@+id/add"
                android:layout_width="40dp"
                android:layout_height="30dp"
                android:layout_marginLeft="60dp"
                android:background="@drawable/minus" />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayout2"
    android:layout_width="fill_parent"
    android:layout_height="100dp"
    android:layout_alignParentTop="true"
    android:layout_toRightOf="@+id/linearLayout1"
    android:background="@color/Thistle"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/save"
        android:layout_width="80dp"
        android:layout_height="50dp"
        android:layout_marginLeft="30dp"
        android:layout_marginTop="30dp"
        android:background="@color/MistyRose"
        android:text="@string/Save" />

    <Button
        android:id="@+id/send"
        android:layout_width="80dp"
        android:layout_height="50dp"
        android:layout_marginLeft="50dp"
        android:layout_marginTop="30dp"
        android:background="@color/MistyRose"
        android:text="@string/Send" />
</LinearLayout>

<ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="800dp"
    android:layout_height="800dp"

    android:layout_alignLeft="@+id/linearLayout2"
    android:layout_below="@+id/linearLayout2" >

    <LinearLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" 
        android:orientation="vertical"
        >


       <HorizontalScrollView 
       android:id="@+id/hv"

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
       >
             <ImageView 
           android:id="@+id/imv"
           android:background="@drawable/blu"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"

           />
   </HorizontalScrollView>
      </LinearLayout>
</ScrollView>

4

1 に答える 1

3

画像をScrollViewとHorizo​​ntalScrollViewに合わせて画像のパンを有効にしようとする代わりに、実装できるかどうかさえわかりません。実装できる場合は、非常に困難な作業になる可能性があります。

PhotoViewライブラリの使用を検討してください。実装は非常に簡単で、すぐに使える魅力のように機能します。さらに、ボーナスとして、マルチタッチとダブルタップを使用したズームをサポートします。

そのページには、それを実装する方法の簡単な例があります。必要なのは、ImageViewXMLでのセットアップだけです。いいえScrollViews、またはHorizontalScrollViewsそれを機能させるために必要です:

ImageView mImageView;
PhotoViewAttacher mAttacher;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Any implementation of ImageView can be used!
    mImageView = (ImageView) findViewById(R.id.iv_photo);

    // Set the Drawable displayed
    Drawable bitmap = getResources().getDrawable(R.drawable.wallpaper);
    mImageView.setImageDrawable(bitmap);

    // Attach a PhotoViewAttacher, which takes care of all of the zooming functionality.
    mAttacher = new PhotoViewAttacher(mImageView);
}


// If you later call mImageView.setImageDrawable/setImageBitmap/setImageResource/etc then you just need to call
attacher.update();
于 2013-02-16T10:46:22.830 に答える