Android ScrollView 不工作

标签 android scrollview

这是我的 .xml 文件,我在其中使用了两个 ScrollView ,一个在输入 Edittext 中,一个在输出 TextView 中。这里出了什么问题...它在 Android 设备上不起作用。

另一个问题是,当我转动我的设备时,它只显示输入文本区域。输出文本区域下降。我想看到输入区域的一半屏幕和输出区域的一半屏幕。

如何解决??

谢谢

  <?xml version="1.0" encoding="utf-8"?>
  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" >

  <LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="35dp"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/test"
        android:layout_width="60dp"
        android:layout_height="38dp"
        android:text="@string/test" />

    <Button
        android:id="@+id/rdf"
        android:layout_width="60dp"
        android:layout_height="38dp"
        android:text="@string/rdf" />

    <Button
        android:id="@+id/load"
        android:layout_width="75dp"
        android:layout_height="38dp"
        android:text="@string/load" />

    <Button
        android:id="@+id/clear"
        android:layout_width="60dp"
        android:layout_height="38dp"
        android:text="@string/clear" />

    <Button
        android:id="@+id/close"
        android:layout_width="fill_parent"
        android:layout_height="38dp"
        android:text="@string/close" />

  </LinearLayout>

   <ScrollView
    android:id="@+id/scrollView1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <EditText
            android:id="@+id/input"
            android:layout_width="0dp"
            android:layout_height="175dp"
            android:layout_weight="1"
            android:background="#fff"
            android:ems="10"
            android:gravity="top|left"
            android:textSize="14dp"
            android:inputType="textMultiLine" >

            <requestFocus />
        </EditText>
    </LinearLayout>
   </ScrollView>

   <Button
    android:id="@+id/run"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="@string/run" />

   <ScrollView
    android:id="@+id/scrollView2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/output"
            android:layout_width="match_parent"
            android:layout_height="225dp"
            android:background="#fff"
            android:text="@string/output"
            android:textColor="#1e90ff" />
    </LinearLayout>
 </ScrollView>

</LinearLayout>

最佳答案

尝试为两个 ScrollView 而不是它们设置 layout_weight=1 和 layout_height=0dp 内容。

关于Android ScrollView 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10669866/

相关文章:

android - 在本地主机上 react native android 连接后端服务

java - 如何在 Android Studio 中创建不相互堆叠的自定义相对布局的滚动列表?

android - ScrollView 不显示

android - 删除listview android中的下划线

android - 将构建机器签名添加到gradle生成的变量

android - 在 for 循环中动态创建按钮以在 ScrollView 中使用

animation - ScrollView 中元素的 SwiftUI 动画不起作用? Xcode GM 更新

android - 旋转 ScrollView

java - AndroidManifest.xml 中的基本错误以获取短信接收权限

java - 检测某个文件夹android中重复文件的最佳方法