Java 如何使RelativeLayout与其片段可滚动科特林

Java 如何使RelativeLayout与其片段可滚动科特林,java,xml,kotlin,scroll,fragment,Java,Xml,Kotlin,Scroll,Fragment,我正在尝试使此XML可滚动: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:fancy="http://

我正在尝试使此XML可滚动:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:fancy="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/square_background"
tools:context=".ejournal.tabs.MyPlannerFragment">



<LinearLayout
    android:id="@+id/linearLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="@dimen/dimen_32"
    android:layout_marginHorizontal="@dimen/dimen_32"
    android:orientation="horizontal">

    <ImageView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginRight="15dp"
        android:layout_gravity="center"
        android:src="@drawable/ic_myplanner"
      />

    <LinearLayout
        android:id="@+id/myplanner_folder"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
       android:layout_marginRight="15dp"
        android:orientation="vertical">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:fontFamily="@font/texgyreadventorregular"
            android:text="My Planner Folder"
            android:textColor="#C18FBC"
            android:textSize="13sp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="left"
            android:fontFamily="@font/texgyreadventorregular"
            android:text="Click here to see all the events you have saved."
            android:textColor="#9D9D9D"
            android:textSize="13sp" />






    </LinearLayout>



</LinearLayout>

<LinearLayout
    android:layout_centerHorizontal="true"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/linearLayout"
    android:orientation="vertical">
    <CalendarView
        android:id="@+id/calender"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_below="@+id/linearLayout"
        android:layout_centerInParent="true"
        android:layout_marginTop="20dp">
    </CalendarView>
    <LinearLayout
        android:gravity="end"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <mehdi.sakout.fancybuttons.FancyButton
            android:id="@+id/btn_add"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingBottom="15dp"
            android:paddingLeft="18dp"
            android:paddingRight="15dp"
            android:paddingTop="15dp"
            fancy:fb_borderColor="#FFFFFF"
            fancy:fb_borderWidth="1dp"
            fancy:fb_defaultColor="@color/purple_600"
            fancy:fb_focusColor="@color/purple_400"
            fancy:fb_fontIconResource="&#xf067;"
            fancy:fb_iconPosition="right"
            fancy:fb_text=""
            fancy:fb_radius="200dp"
            fancy:fb_textColor="#FFFFFF" />
    </LinearLayout>
    <LinearLayout
        android:gravity="center"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:textAlignment="center"
            android:text="Pick a date to add your Daily Task/ Event"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:gravity="center_horizontal" />
    </LinearLayout>

</LinearLayout>
我把“container”改为“scrollview”,但还是一样的错误

我还尝试将其添加到xml中:

<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"/>

但效果不太好

我做错了什么


我是否只需要对XML文件进行更改?还是同时使用片段和xml?

将您的相对布局替换为ScrollView,或者让相对布局的父级希望这能帮助您解决问题

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#fcf5eb"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:fitsSystemWindows="true"
   >

<Linear Layout>
.....





.....
</Linear Layout>

</Scrollview>



.....
.....

将您的相对布局替换为ScrollView,或者让相对布局的家长希望这能帮助您解决问题

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#fcf5eb"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:fitsSystemWindows="true"
   >

<Linear Layout>
.....





.....
</Linear Layout>

</Scrollview>



.....
.....

每当我用SrcollView替换相对布局时,我都会在这一行中得到一个错误“val root=inflater.inflate(R.Layout.fragment\u my\u planner,container,false)”每当我用SrcollView替换相对布局时,我都会在这一行中得到一个错误“val root=inflater.inflate”(R.layout.fragment_my_planner,container,false)“在片段中