我想使布局可以使用scrollview滚动,但它根本无法工作。试图使用NestedScrollView更改滚动视图,但问题仍然相同。此布局用于片段。将LinearLayout放入滚动视图中作为视图。如果我做错了,谁能帮助我更正我的代码?下面是我的xml代码
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:background="@android:color/white"
android:orientation="vertical"
tools:context=".ui.jobCalendar.JobCalendarFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.applandeo.materialcalendarview.CalendarView
android:id="@+id/calendarView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:headerColor="@color/colorPrimaryDark" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_calendar"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary">
<TextView
android:padding="10dp"
style="@style/TextContent.Black"
android:layout_marginBottom="8dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:text="Schedule"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/listJob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin"
tools:listitem="@layout/job_row">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
预先感谢
答案 0 :(得分:0)
执行此操作
1)将根布局更改为
RelativeLayout
2)将ScrollView的高度设置为
wrap_content
3)将ScrollView子级(LinearLayout)的 height 更改为
match_parent
4)将此行添加到该activity
的主机fragment
<activity
android:name="Activity_name"
android:windowSoftInputMode="stateHidden|adjustResize" />
最后xml
看起来像:-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:fillViewport="true"
android:orientation="vertical"
tools:context=".ui.jobCalendar.JobCalendarFragment">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:fillViewport="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.applandeo.materialcalendarview.CalendarView
android:id="@+id/calendarView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:headerColor="@color/colorPrimaryDark" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_calendar"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorPrimary">
<TextView
style="@style/TextContent.Black"
android:layout_marginBottom="8dp"
android:layout_marginTop="@dimen/activity_vertical_margin"
android:padding="10dp"
android:text="Schedule"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/listJob"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/activity_vertical_margin"
tools:listitem="@layout/job_row">
</android.support.v7.widget.RecyclerView>
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
答案 1 :(得分:0)
我认为您需要摆脱ScrollView属性中的那些设置。
基本上将其缩短为
$.getJSON('/stData/' + article, function (data) {
$.each(data.response, function (inc) {
data.response[inc].Subject, data.response[inc].Summary]);
});
table2.draw();
将其余设置放入ScrollView中包含的RelativeLayout中,如下所示:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">