java - 在我对我的 android 应用程序原型的模拟中,滚动视图(线性布局)没有滚动
问题描述
在我的 android 应用程序中,我在滚动视图中有一个线性布局,但是当我在模拟器中打开应用程序时,我无法滚动滚动视图。
我不知道这是否是解决方案,但我没有使用鼠标,而只是使用我的触摸板,当我尝试 2 指滚动时,模拟器的行为就像我按下按钮一样。我试图将 fillViewport 函数放入其中,但它仍然无法正常工作。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout 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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".HomeScreen">
<Button
android:id="@+id/settingsNavigator"
android:layout_width="0dp"
android:layout_height="110dp"
android:layout_marginTop="40dp"
android:text="SETTINGS"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textView" />
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="45dp"
android:text="Not connected"
android:textAlignment="center"
android:textColor="#FF0000"
android:textSize="30sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/button5" />
<Button
android:id="@+id/button5"
android:layout_width="0dp"
android:layout_height="120dp"
android:layout_marginTop="25dp"
android:text="Button"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ScrollView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="55dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/settingsNavigator">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<Button
android:id="@+id/button15"
android:layout_width="match_parent"
android:layout_height="90dp"
android:text="Button" />
<Button
android:id="@+id/button14"
android:layout_width="match_parent"
android:layout_height="90dp"
android:text="Button" />
<Button
android:id="@+id/button13"
android:layout_width="match_parent"
android:layout_height="90dp"
android:text="Button" />
<Button
android:id="@+id/button12"
android:layout_width="match_parent"
android:layout_height="90dp"
android:text="Button" />
<Button
android:id="@+id/button11"
android:layout_width="match_parent"
android:layout_height="90dp"
android:text="Button" />
<Button
android:id="@+id/button10"
android:layout_width="match_parent"
android:layout_height="90dp"
android:text="Button" />
</LinearLayout>
</ScrollView>
</android.support.constraint.ConstraintLayout>
应用程序构建工作正常,但滚动是唯一不工作的。
解决方案
好吧,实际上我自己很快就明白了。好像我早就问了很多这个问题而没有真正考虑过。尽管该解决方案可能对其他人有所帮助:
我只是把所有东西都放在另一个 LinearLayout 中。这解决了问题。现在只有底部在滚动,而上部保持不变,这正是我想要的。
推荐阅读
- julia - 如何绘制两个直方图之间的差异?(朱莉娅)
- python-3.x - 如何使用 selenium python 上传多个/单个文件?
- react-native - 深度链接到反应导航 v5 中的嵌套屏幕以进行反应原生
- sql-server - 哪些表包含工作类别类和类型?
- python - 有没有办法使用另一个列表的索引将项目添加到熊猫列内的列表中?
- c - 无法获得正确的阵列定位器长度
- c# - 如何检测连接的 USB 设备是 android 还是 iphone?(C#)
- python - mypy - 可使用派生类调用会出错
- python - Azure 应用服务:从 FTP 下载文件突然停止
- javascript - 如何在JS中将每一行变成一个列表