1

このようなスクロールビューを追加するだけで、画面が読み込まれた後、黒い背景が表示されます。

この黒い領域は、周囲のRelativeLayoutの左上隅に配置されます。スクロールビューがandroid:layout_marginLeft="20dp" android:layout_marginTop="40dp"Soで配置されている間、左側の20dpと上部の40dpは黒で、残りの灰色の背景はそのままです。

ここに、scrollViewを含むxml部分があります。

  <View
            android:id="@+id/emptyView"
            android:layout_width="match_parent"
            android:layout_height="2dp"
            android:layout_below="@+id/right1" />

        <RelativeLayout
            android:id="@+id/right2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/emptyView" >

            <RelativeLayout
                android:id="@+id/right22"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/emptyView" >

                <ImageView
                    android:id="@+id/emptyView2"
                    android:layout_width="match_parent"
                    android:layout_height="2dp"
                    android:contentDescription="@string/anyStringValue" />

                <HorizontalScrollView
                    android:id="@+id/scrollView"
                    android:layout_width="fill_parent"
                    android:layout_height="520dp"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="40dp"
                    android:background="#0000FF" >

                    <TextView
                        android:id="@+id/infoTxt"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:background="#FF0000"
                        android:padding="10dp"
                        android:text="@string/Settings_infoTxt"
                        android:textColor="#000000"
                        android:textSize="20dp" />
                </HorizontalScrollView>
            </RelativeLayout>
        </RelativeLayout>

スクロールビューの上にemptyViewと2つのRelativeLayoutsを追加しようとしました。しかし、黒い領域は何があっても表示され続けます。(RelativeLayoutsと上部の空のビューがある場合とない場合)

ページ全体の背景が灰色であるため、この黒い領域が画面全体を歪めます。

以前はスクロールビューを何度も使用していましたが、このような問題は発生しませんでした。何が原因なのかわかりません。

スクロールビューによって引き起こされた黒い領域を取り除くにはどうすればよいですか?

どうもありがとう!

4

1 に答える 1

2

私はほとんど同じ問題を抱えていました.スクロールビューをロードするといくつかの黒い領域が現れ、それらはタッチすると消えました. スクロールビューの背景色を設定しないことで解決しました。コンテンツ ビューの背景色を設定するだけで十分です。

      //outer layout, where black shapes appear
    LinearLayout outer = new LinearLayout(context);
    outer.setBackgroundColor(Color.MAGENTA);

    ScrollView list = new ScrollView(context);
    list.setLayoutParams(new LayoutParams(100, 300));

    //        do not set the background color here, this causes the blak shapes
    //        list.setBackgroundColor(Color.CYAN);
    //        add an inner layout to the scrollView and set the background of the innerlayout
    LinearLayout linearLayout = new LinearLayout(context);
    linearLayout.setBackgroundColor(Color.CYAN);
    linearLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT));

    list.addView(linearLayout);
    outer.addView(list);
于 2012-07-05T12:37:55.823 に答える