0

ScrollView に問題があります。その中に ImageView があります。imageView は、480 * 3000 ピクセルの画像を保持します。そのため、ユーザーが下にスクロールできるように、ScrollView にする必要があります。

問題は、アプリケーションをテストすると、ScrollView が画像の高さにラップしないことです。画像の下に黒いスペースがありますが、これは私には奇妙です。

これは私の XML コードです。ご意見お待ちしております

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <ScrollView
    android:id="@+id/scroll_view"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:scrollbars="vertical" >    
        <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/image"
        android:src="@drawable/image01"
        android:scaleType="fitStart" />     
    </ScrollView>
</RelativeLayout>

更新: これは、@ruhalde コードを使用した場合のイメージです。大きくて全体像が見えないのでスクリーンショットが撮れないので描いてみました。

ここに画像の説明を入力

4

4 に答える 4

0

レイアウトを書き直します。ScrollView を最も外側の要素にします。詳細については、この優れたチュートリアルをご覧ください: http://mobiforge.com/designing/story/understanding-user-interface-android-part-1-layouts

于 2011-08-22T01:13:04.127 に答える
0

興味のある方へ:

私の問題は、レイアウトの整理方法ではなく、使用している画像にありました。ありがとう。

于 2012-01-12T00:51:20.777 に答える
0

現在廃止されている RelativeLayout の代わりに LinearLayout を使用してください。ScrollView XML で fillViewPort=true を設定するか、必要に応じてプログラムで setFillViewPort(true) を設定します。

imageview を LinearLayout 内に配置し、それを ScrollView 内に配置すると、XML は次のようになります。

LinearLayout ---ScrollView ----LinearLayout ------ImageView

800 x 4000 ピクセルの画像で、完全に垂直方向にスクロールする XML を確認してください。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <ScrollView android:id="@+id/scrollView1"
        android:layout_width="fill_parent" android:layout_height="wrap_content">
        <LinearLayout android:id="@+id/linearLayout1"
            android:layout_width="fill_parent" android:layout_height="fill_parent">
            <ImageView android:id="@+id/mapa" android:layout_height="wrap_content"
                android:layout_width="wrap_content"></ImageView>
        </LinearLayout>
    </ScrollView>

</LinearLayout>
于 2011-08-22T02:17:01.687 に答える
-1

layout タグの前に scrollView タグを使用する必要があると思います

于 2011-08-22T01:28:36.073 に答える