-1

When I use ScrollView, no matter how I set it up, Scrollview will always have a green border, setting the background to Scorllview doesn’t work.

enter image description here

Below is part of my xml file

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

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal">

        <ScrollView
            android:id="@+id/left_sv"
            android:layout_width="@dimen/px_180"
            android:layout_height="match_parent"
            android:overScrollMode="never"
            android:background="@null"
            android:scrollbars="none"
            android:fadingEdge="none" >

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

                <RelativeLayout
                    android:id="@+id/rl_setting_quota"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/px_50"
                    android:gravity="center_vertical">

                    <ImageView
                        android:layout_width="@dimen/px_30"
                        android:layout_height="@dimen/px_30"
                        android:layout_marginLeft="@dimen/px_10"
                        android:src="@drawable/icon_szxianling" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="@dimen/px_30"
                        android:layout_marginLeft="@dimen/px_40"
                        android:gravity="center"
                        android:text="@string/str_setting_quota"
                        android:textSize="@dimen/px_16" />

                    <ImageView
                        android:id="@+id/iv_arr_setting_quota"
                        android:layout_width="@dimen/px_15"
                        android:layout_height="@dimen/px_15"
                        android:layout_alignParentRight="true"
                        android:layout_marginRight="@dimen/px_10"
                        android:src="@drawable/arrow_right" />
                </RelativeLayout>

                <View
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/px_1"
                    android:background="@drawable/line_shape" />

                <RelativeLayout
                    android:id="@+id/rl_setting_time"
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/px_50"
                    android:gravity="center_vertical">

                    <ImageView
                        android:layout_width="@dimen/px_30"
                        android:layout_height="@dimen/px_30"
                        android:layout_marginLeft="@dimen/px_10"
                        android:src="@drawable/icon_shijian" />

                    <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="@dimen/px_30"
                        android:layout_marginLeft="@dimen/px_40"
                        android:gravity="center"
                        android:text="@string/str_setting_time"
                        android:textSize="@dimen/px_16" />

                    <ImageView
                        android:id="@+id/iv_arr_setting_time"
                        android:layout_width="@dimen/px_15"
                        android:layout_height="@dimen/px_15"
                        android:layout_alignParentRight="true"
                        android:layout_marginRight="@dimen/px_10"
                        android:src="@drawable/arrow_right" />
                </RelativeLayout>

            

                <View
                    android:layout_width="match_parent"
                    android:layout_height="@dimen/px_1"
                    android:layout_marginBottom="@dimen/px_30"
                    android:background="@drawable/line_shape" />
            </LinearLayout>
        </ScrollView>

        

        </LinearLayout>
    </LinearLayout>

</LinearLayout>
The LinearLayout label is my root layout, there is a ScrollView layout inside, a LinearLayout layout is placed in the ScrollView, and then there are multiple RelativeLayout layouts in the LinearLayout layout

1 Answers1

0

I have discovered the reason for this problem. This problem occurs because of the focus problem, not the problem of the Scrollview itself, because the focus is transferred to the Scrollview as soon as the interface is entered. You only need to set the following two parameters in the parent layout of the ScrollView. Can solve the problem: android:focusable="true" android:focusableInTouchMode="true"