我的布局中有header
,标题下方有scrollview
。当我开始填充scrollview
中的内容(以便我滚动页面)时,scrollview
开始在标题顶部滚动
bucket.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rel_rootMyBucketList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_mybuket_list"
android:orientation="vertical">
<include
android:id="@+id/bucket_header"
layout="@layout/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"></include>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/bucket_header">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
android:id="@+id/bucket_row_1"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"></include>
<include
android:id="@+id/bucket_row_2"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_1"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_3"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_2"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_4"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_3"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_5"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_4"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_6"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_5"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_7"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_6"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_8"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_7"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_9"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_8"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_10"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_9"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_11"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_10"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_12"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_11"
android:visibility="gone"></include>
</LinearLayout>
</ScrollView>
</RelativeLayout>
header.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cyan_dark"
android:paddingTop="20dp">
<ImageView
android:id="@+id/img_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="30dp"
android:paddingTop="10dp"
android:src="@drawable/ic_back" />
<ImageView
android:id="@+id/img_search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:paddingBottom="10dp"
android:paddingLeft="10dp"
android:paddingRight="30dp"
android:paddingTop="10dp"
android:src="@drawable/btn_home_search"
android:visibility="gone" />
<TextView
android:id="@+id/tv_header_tittle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:gravity="center"
android:padding="10dp"
android:text="Change Password"
android:textColor="@color/white"
android:textSize="@dimen/txt_large" />
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/circle_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_header_tittle"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:background="#512da8"
app:fillColor="@color/white"
app:pageColor="@color/blue"
app:strokeColor="@color/blue"
android:visibility="gone"/>
<ImageView
android:id="@+id/img_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingBottom="10dp"
android:paddingLeft="30dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:src="@drawable/ic_bucketlist_next"
android:visibility="gone" />
<TextView
android:id="@+id/tv_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/next"
android:textColor="@android:color/white"
android:textSize="@dimen/txt_medium"
android:layout_alignParentRight="true"
android:padding="10dp"
android:visibility="gone"
android:layout_centerHorizontal="true" />
<ImageView
android:id="@+id/img_glob"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:paddingBottom="10dp"
android:paddingLeft="30dp"
android:paddingRight="10dp"
android:paddingTop="10dp"
android:src="@drawable/ic_home_globe"
android:visibility="gone" />
答案 0 :(得分:2)
首先使用RelativeLayout
(家长)代替LinearLayout
。
然后在android:layout_below
ScrollView
<强>机器人:layout_below 强>
将此视图的上边缘定位在给定的锚点视图ID下方。 容纳此视图的上边距和锚视图的下边距。
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/bucket_header">
<强>被修改强>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bucket_header">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
答案 1 :(得分:0)
添加
android:layout_below="@+id/bucket_header"
到你的scrollView
答案 2 :(得分:0)
试试这个,
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rel_rootMyBucketList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_mybuket_list"
android:orientation="vertical">
<include
android:id="@+id/bucket_header"
layout="@layout/header"
android:layout_width="match_parent"
android:layout_height="wrap_content"></include>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/bucket_header"
android:orientation="vertical">
<include
android:id="@+id/bucket_row_1"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"></include>
<include
android:id="@+id/bucket_row_2"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_1"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_3"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_2"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_4"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_3"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_5"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_4"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_6"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_5"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_7"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_6"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_8"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_7"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_9"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_8"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_10"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_9"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_11"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_10"
android:visibility="gone"></include>
<include
android:id="@+id/bucket_row_12"
layout="@layout/row_my_bucket"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_below="@+id/bucket_row_11"
android:visibility="gone"></include>
</LinearLayout>
</ScrollView>
</LinearLayout>
答案 3 :(得分:0)
尝试在scrollview中添加此内容并尝试将相对布局更改为线性布局。
android:fillViewport = "true"