我的滚动视图在 header android 上方滚动
My scrollview scrolls above the header android
我的布局中有一个 header
,scrollview
在 header 下方。当我开始在 scrollview
中填充内容(这样我就可以滚动页面)时,scrollview
开始在 header
的顶部滚动
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" />
添加
android:layout_below="@+id/bucket_header"
到你的 scrollView
试试这个,
<?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>
首先使用 RelativeLayout
(父)代替 LinearLayout
。
然后在ScrollView
中调用android:layout_below
android:layout_below
Positions the top edge of this view below the given anchor view ID.
Accommodates top margin of this view and bottom margin of anchor view.
<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"
>
尝试在滚动视图中添加它并尝试将相对布局更改为线性布局。
android:fillViewport = "true"
我的布局中有一个 header
,scrollview
在 header 下方。当我开始在 scrollview
中填充内容(这样我就可以滚动页面)时,scrollview
开始在 header
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" />
添加
android:layout_below="@+id/bucket_header"
到你的 scrollView
试试这个,
<?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>
首先使用 RelativeLayout
(父)代替 LinearLayout
。
然后在ScrollView
android:layout_below
android:layout_below
Positions the top edge of this view below the given anchor view ID. Accommodates top margin of this view and bottom margin of anchor view.
<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"
>
尝试在滚动视图中添加它并尝试将相对布局更改为线性布局。
android:fillViewport = "true"