【问题标题】:making Multiple EditText's scroll inside scrollview在滚动视图中制作多个 EditText 的滚动
【发布时间】:2014-05-05 10:01:27
【问题描述】:

我正在尝试让编辑文本滚动,以防视图不是全部。当键盘打开或关闭时,用户应该能够滚动编辑文本。

我尝试了linearLayout 和ScrollView 的多种组合,但似乎不起作用。

有人可以检查一下有什么问题吗?

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

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#FFFFFF"
        android:orientation="vertical" >

        <TextView
            android:id="@+id/description"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_marginTop="50dp"
            android:text="Details"
            android:textColor="#EB8024"
            android:textSize="30sp" />

        <EditText
            android:id="@+id/name"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="40dp"
            android:background="@drawable/theme_textfield_activated_holo_light"
            android:ems="10"
            android:hint="URI"
            android:inputType="text" />

        <EditText
            android:id="@+id/ip_addr"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:background="@drawable/theme_textfield_activated_holo_light"
            android:ems="10"
            android:hint="IP Address"
            android:inputType="text" />

        <EditText
            android:id="@+id/port"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:background="@drawable/theme_textfield_activated_holo_light"
            android:ems="10"
            android:hint="Port"
            android:inputType="text" />

        <EditText
            android:id="@+id/app_name"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:background="@drawable/theme_textfield_activated_holo_light"
            android:ems="10"
            android:hint="Application Name"
            android:inputType="text" />

        <EditText
            android:id="@+id/string"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="30dp"
            android:background="@drawable/theme_textfield_activated_holo_light"
            android:ems="10"
            android:hint="Nick Names"
            android:inputType="text" />

        <Button
            android:id="@+id/submit"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal"
            android:layout_marginTop="20dp"
            android:background="@drawable/theme_btn_default_disabled_focused_holo_light"
            android:onClick="onClickNext"
            android:text="Next"
            android:textColor="#EB8024"
            android:textSize="30sp" />
    </LinearLayout>

</ScrollView>

【问题讨论】:

  • 当你尝试使用你的代码时会发生什么??
  • @Lal 正常启动但根本不滚动
  • 你试过android:fillViewport="true"
  • 您能否尝试在您的 AndroidManiFest.xml 中的
  • 也可以尝试移除 height 和 width 属性..

标签: android scroll android-edittext scrollview


【解决方案1】:

让您的ScrollView 填充视口并匹配父级的高度,而不是包裹内容。

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fillViewport="true">

【讨论】:

  • 完成。不工作。没有报告错误,但滚动也不起作用
  • 那不行..请看这个link
  • @Lal 它对我有用。抱歉,Raj,这对您没有帮助。
猜你喜欢
  • 2014-06-12
  • 2011-06-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多