Android ScrollView在布局中不工作
屏幕没有滚动。屏幕还包含滑动刷新。 我尝试了不同的解决方案并添加了这一行Android ScrollView在布局中不工作 ,android,xml,Android,Xml,屏幕没有滚动。屏幕还包含滑动刷新。 我尝试了不同的解决方案并添加了这一行 android:fillViewport=“true” 并删除了相对布局的方向 为什么滚动视图不在这里工作 但屏幕并没有滚动。我是android新手 请帮帮我。任何帮助都将不胜感激 谢谢。尝试使用
android:fillViewport=“true”
并删除了相对布局的方向
为什么滚动视图不在这里工作
但屏幕并没有滚动。我是android新手
请帮帮我。任何帮助都将不胜感激
谢谢。尝试使用
和
而不是
和列表视图
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="vertical" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/sw_ManualRefresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Today"
android:textAllCaps="true"
android:layout_marginTop="20dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:textColor="@color/primary_dark"
android:textSize="20sp"
android:layout_alignLeft="@+id/view"
android:layout_alignStart="@+id/view" />
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="1.7dp"
android:background="@color/accent"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="0dp"
android:layout_marginRight="8dp"
android:layout_below="@id/textView5"
/>
<ListView
android:id="@+id/list_Today_plan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_below="@+id/view"
android:layout_marginLeft="15dp"
android:layout_alignRight="@+id/list_Upcoming_plans"
android:layout_alignEnd="@+id/list_Upcoming_plans" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Upcoming"
android:textAllCaps="true"
android:textColor="@color/primary_dark"
android:textSize="20sp"
android:layout_below="@id/list_Today_plan"
android:layout_alignLeft="@+id/view2"
android:layout_alignStart="@+id/view2" />
<View
android:id="@+id/view2"
android:layout_width="match_parent"
android:layout_height="1.7dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="13dp"
android:layout_marginStart="8dp"
android:background="@color/accent"
android:layout_below="@id/textView6"
/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:id="@+id/list_Upcoming_plans"
android:layout_below="@id/view2"/>
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</ScrollView>
您应该将ScrollView
放在小部件的内部。SwipeRefreshLayout
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:scrollbars="vertical" >
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/sw_ManualRefresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Today"
android:textAllCaps="true"
android:layout_marginTop="20dp"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:textColor="@color/primary_dark"
android:textSize="20sp"
android:layout_alignLeft="@+id/view"
android:layout_alignStart="@+id/view" />
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="1.7dp"
android:background="@color/accent"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:layout_marginTop="0dp"
android:layout_marginRight="8dp"
android:layout_below="@id/textView5"
/>
<ListView
android:id="@+id/list_Today_plan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:layout_below="@+id/view"
android:layout_marginLeft="15dp"
android:layout_alignRight="@+id/list_Upcoming_plans"
android:layout_alignEnd="@+id/list_Upcoming_plans" />
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Upcoming"
android:textAllCaps="true"
android:textColor="@color/primary_dark"
android:textSize="20sp"
android:layout_below="@id/list_Today_plan"
android:layout_alignLeft="@+id/view2"
android:layout_alignStart="@+id/view2" />
<View
android:id="@+id/view2"
android:layout_width="match_parent"
android:layout_height="1.7dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="13dp"
android:layout_marginStart="8dp"
android:background="@color/accent"
android:layout_below="@id/textView6"
/>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:id="@+id/list_Upcoming_plans"
android:layout_below="@id/view2"/>
</RelativeLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</RelativeLayout>
</ScrollView>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView01"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:fitsSystemWindows="true"
android:scrollbars="vertical">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/sw_ManualRefresh"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/view"
android:layout_alignStart="@+id/view"
android:layout_marginTop="20dp"
android:text="Today"
android:textAllCaps="true"
android:textSize="20sp" />
<View
android:id="@+id/view"
android:layout_width="match_parent"
android:layout_height="1.7dp"
android:layout_below="@id/textView5"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="0dp"
android:background="@color/colorAccent" />
<android.support.v7.widget.RecyclerView
android:id="@+id/list_Today_plan"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginTop="12dp"
android:nestedScrollingEnabled="false" />
<TextView
android:id="@+id/textView6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Upcoming"
android:textAllCaps="true"
android:textColor="@color/colorPrimaryDark"
android:textSize="20sp" />
<View
android:id="@+id/view2"
android:layout_width="match_parent"
android:layout_height="1.7dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="13dp"
android:layout_marginStart="8dp"
android:background="@color/colorAccent"
/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:nestedScrollingEnabled="false"
android:visibility="visible" />
</LinearLayout>
</android.support.v4.widget.SwipeRefreshLayout>
</android.support.v4.widget.NestedScrollView>
//您可以在此处滚动查看内容和其他布局
尝试使用Recycyerview而不是ListView,然后scrollView将完美工作。因为scrollView
和swipeRefresh
将上下滑动冲突,您需要解决冲突。这不是一个答案,因为OP需要刷新scrollView内部而不是外部的内容