简体   繁体   中英

Android ScrollView remove border

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.

在此处输入图像描述

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

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"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM