0

アプリで 5 つの画像のリストの水平スクロールを作成しようとしました。アプリで次の XML を記述しました。私が直面している問題は、画面の左右に空白の領域が残ることです。つまり、画像リストが開始される前の空白領域と、画像リストの後の空白領域です。

XML

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" 
    android:layout_gravity="center">



    <LinearLayout
        android:id="@+id/LinearLayout02"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:paddingRight="20dp"
            android:src="@drawable/people" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:paddingRight="20dp"
            android:src="@drawable/people" />

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:paddingRight="20dp"
            android:src="@drawable/people" />

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:paddingRight="20dp"
            android:src="@drawable/people" />
    </LinearLayout>

</HorizontalScrollView>

この不要な空白領域を削除する方法を教えてもらえますか? ここに画像の説明を入力 NagarjunaReddy の提案を試してみましたが、下のスクリーンショットに示すような結果が得られました。

4

4 に答える 4

1

私は私の質問に対する答えを得ました。実際、この空白スペースは私のモバイルシステムオペレーティングシステムandroidversin4.0のために来ています。android ver2.3で同じアプリをチェックしたところ、とにかく空白が表示されません。

于 2013-02-07T07:56:27.477 に答える
0

OSのバージョンは関係ありません。これを試して:

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<LinearLayout
    android:id="@+id/LinearLayout02"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/people" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/people" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/people" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:src="@drawable/people" />
</LinearLayout>

次のようなものを取得する必要があります。 グラフィカル レイアウト エディタから

于 2013-02-07T08:02:23.967 に答える
0

android:paddingRight="20dp"すべての<ImageView>sを削除します

于 2013-02-07T06:23:23.617 に答える
0

これを試して、すべてのイメージビューのパディングを削除してくださいandroid:paddingRight="20dp"

<LinearLayout
    android:id="@+id/LinearLayout02"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:layout_weight="1"
    android:orientation="horizontal" >

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"          
        android:src="@drawable/people" />

    <ImageView
        android:id="@+id/imageView2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"            
        android:src="@drawable/people" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"            
        android:src="@drawable/people" />

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"           
        android:src="@drawable/people" />
</LinearLayout>

于 2013-02-07T06:21:15.783 に答える