android - (嵌套)ScrollView 不滚动到底部
问题描述
我尝试了很多答案,但我认为我的 ScrollView 包含更多元素。
即使我尝试使用 NestedScrollView、底部边距、填充,甚至在子布局上使用 android:descendantFocusability="blocksDescendants" 以及另一个包含 ScrollView 中每个元素的大型线性布局,但没有结果......
问题是我的 ScrollView 没有滚动到它的视图底部。我不得不说滚动视图低于设置为 35% 的水平线,这可能是造成这种可憎的原因之一吗?
我将插入一个 XML 代码示例
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.35" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/guideline"
app:layout_constraintVertical_bias="0.0">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:descendantFocusability="blocksDescendants"
android:baselineAligned="false"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/linearLayout_dummy1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:orientation="horizontal" />
<!-- This is the part that's 85% of the total width.-->
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.9"
android:orientation="vertical">
<LinearLayout
android:id="@+id/linearLayoutInside"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/anotherlayout"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_weight="1"
android:background="@drawable/rounded_shape"
android:baselineAligned="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.26"
android:orientation="horizontal">
....
....
much more linear and constraints layouts that opens then closes
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!--Width 85% ends-->
<LinearLayout
android:id="@+id/linearLayout_dummy2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight=".1"
android:orientation="horizontal" />
</LinearLayout>
</ScrollView>
此外,这是一个“图像”(不要笑——不要太难:))显示不滚动时的显示效果。如果我滚动它不会到达它的底部:
解决方案
您的 xml 布局中有一些错误。缺少两个线性布局的关闭标签,您的滚动视图应位于指南小部件内。
推荐阅读
- microsoft-graph-api - Microsoft Graph API 支持 applicationRefs 信息
- python - 有没有一种使用 Python Openpyxl 在 Excel 中写入数据的简洁方法?
- r - 如何使用条件连接两个表
- node.js - 无法让 React + socket.io 在 Heroku 上工作
- r - 使用 R Shiny 中的 actionButton 更新新表并添加行
- pandas - 多列上的 Lambda 函数
- java - 从 OpenCV.jar 库导入时无法识别 [Java]
- ios - 在 Firestore 集合内的唯一文档内查询
- javascript - 获取对象中的多个 url 反应
- python - 将列表拆分为事件分布的块