Android 无法滚动放置在ScrollView中的LinearLayout
我参考了Stackoverflow中与此主题相关的大多数问题,并成功地将线性布局放置在滚动视图中。但我不能滚动它。我的活动大纲是- 下面是ScrollView的XML代码-Android 无法滚动放置在ScrollView中的LinearLayout,android,scrollview,android-linearlayout,Android,Scrollview,Android Linearlayout,我参考了Stackoverflow中与此主题相关的大多数问题,并成功地将线性布局放置在滚动视图中。但我不能滚动它。我的活动大纲是- 下面是ScrollView的XML代码- <ScrollView android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:id="@+id/linearLayoutUP1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewUP1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/Chocolate"
android:gravity="center"
android:padding="10dp"
android:text=" "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/Black"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewUP2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Chocolate"
android:gravity="center"
android:padding="10dp"
android:text="User ID : "
android:textColor="@color/White"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewUP4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/Chocolate"
android:gravity="center"
android:padding="10dp"
android:text="Gender : "
android:textColor="@color/White"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="vertical" >
<TextView
android:id="@+id/textViewUP3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/Chocolate"
android:gravity="center"
android:padding="10dp"
android:text="Your Groups"
android:textColor="@color/White"
android:textSize="16sp"
android:textStyle="bold" />
<GridView
android:id="@+id/gridViewUP1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="1"
android:padding="5dp" >
</GridView>
</LinearLayout>
</LinearLayout>
</ScrollView>
如您所见,在最后一个LinearLayout中有一个GridView。此GridView在添加ScrollView之前是可滚动的。添加ScrollView后,无法滚动名为“linearLayoutUP1”的布局。如何使其垂直滚动?我认为在Android中嵌套可滚动视图被认为是糟糕的设计,可能无法正常工作。GridView本质上是可滚动的
如果您想保留它,请尝试查看此处:不建议您在ScrollView中使用任何类型的可滚动视图 您可能想在您的案例中检查一下,看看它是否有效
尝试对第一条直线布局的高度进行硬编码。即将
包装内容
更改为大约1000 dp。这将使其可滚动。我一点也不确定这是否是解决问题的正确方法,但我告诉你当我面对同样的情况时我做了什么
另外,如果您使用的是android:theme=“@android:style/theme.NoTitleBar.Fullscreen”
。请尝试将其更改为android:theme=“@android:style/theme.NoTitleBar”
。即没有全屏
再次检查清单中的活动标记是否有android:WindowsOfInputMode=“adjustPan”。如果是,请在删除该标记后重试
这些都是我在面对类似情况时尝试和运用的解决方案
android活动始终开始滚动到底部要解决此问题,请将android:focusableInTouchMode=“true”添加到您的
线性布局中。
。您可以发布您的代码吗。为了在seedependencies.post中添加xml文件,请尝试将android:fillViewport=“true”
添加到ScrollView
@Lal现在出现滚动条,但我仍然无法滚动。请尝试硬编码第一行布局的高度..即将wrap_内容更改为1000dp左右..仅用于测试..我应该如何编辑代码以使其正常工作?我将活动扩展到我的类,在您提供的示例中,GridView扩展到该类。