Java Scrollview在android studio上不工作?

Java Scrollview在android studio上不工作?,java,android,user-interface,android-scrollview,Java,Android,User Interface,Android Scrollview,我尝试了不同的方法,甚至把整件事都做了一遍,我不知道为什么它不起作用。需要帮忙吗?每当我添加另一张卡片而不是滚动视图时,它只会占用屏幕上更多的空间,从而减小所有其他元素的大小。我是初学者,所以如果我犯了任何愚蠢的错误,我向你道歉 您必须将滚动视图放在布局中,这样它才能正常工作 <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:weightSum="1.

我尝试了不同的方法,甚至把整件事都做了一遍,我不知道为什么它不起作用。需要帮忙吗?每当我添加另一张卡片而不是滚动视图时,它只会占用屏幕上更多的空间,从而减小所有其他元素的大小。我是初学者,所以如果我犯了任何愚蠢的错误,我向你道歉


您必须将滚动视图放在布局中,这样它才能正常工作

<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1.5"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<ScrollView android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent">

  <!--put your nested layouts and other things which you want to use for 
  scrolling-->

</LinearLayout>
 </ScrollView>
   </LinearLayout>

请记住,滚动视图只允许其中一个布局


上述代码肯定会帮助您

而不是使用GridLayout使用RecyclerView和用户适配器动态添加卡片

您已经在cardview中提供了
android:layout\u rowWeight=“1”
删除该行并为
android:Layou height=“wrap\u content”添加高度
或在所有卡片视图中的一些值,如
android:layout\u height=“250dp”


ScrollView

@Zoe没有问题,我的项目使用的是android studio。这是我项目的一部分,不仅仅是一些代码。那么?您并没有特别询问,无论您使用的是Android Studio、Eclipse还是将某些东西拼凑在一起并使用Vim,代码都是相同的。看@Zoe我什么时候应该使用标签?你能给我举个例子吗?改用android标签(你已经用过了,所以唯一需要做的就是删除android Studio标签)。另请参见我尝试过的代码,它不起作用。请显示更新的代码。我会尝试这样做
<LinearLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1.5"
android:orientation="vertical"
xmlns:android="http://schemas.android.com/apk/res/android">

<ScrollView android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
xmlns:android="http://schemas.android.com/apk/res/android">

    <LinearLayout
    android:layout_width="match_parent"
    android:orientation="vertical"
    android:layout_height="match_parent">

  <!--put your nested layouts and other things which you want to use for 
  scrolling-->

</LinearLayout>
 </ScrollView>
   </LinearLayout>