繁体   English   中英

Android ScrollView 移除边框

[英]Android ScrollView remove border

在我使用ScrollView的时候,不管怎么设置,Scrollview总是会有绿色边框,设置背景为Scorllview是不行的。

在此处输入图像描述

下面是我的 xml 文件的一部分

 <?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>
LinearLayout label是我的根布局,里面有一个ScrollView布局,一个LinearLayout布局放在ScrollView里面,然后LinearLayout布局里面有多个RelativeLayout布局

我已经发现了这个问题的原因。 出现这个问题是因为焦点问题,而不是Scrollview本身的问题,因为一进入界面焦点就转移到了Scrollview上。 只需要在ScrollView的父布局中设置以下两个参数即可。 可以解决问题:android:focusable="true" android:focusableInTouchMode="true"

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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