android编辑文本焦点

时间:2011-09-06 10:49:43

标签: android search

我在布局上有两个编辑文本,加载时光标必须在第二个编辑文本上。以及如何在加载时在键盘上方移动编辑文本。重新属性不起作用。提前谢谢

3 个答案:

答案 0 :(得分:1)

您只需在滚动视图中添加布局,它就会自动向上滚动,以便编辑文字在键盘上方。

答案 1 :(得分:0)

使用editText2.requestFocus();将光标移到第二个EditText。然后EditText会自动向上移动。

答案 2 :(得分:0)

在editText中使用android:enabled = true。使用RelativeLayout创建视图,尽量不直接给出editText的高度。如果你这样做,你的清单中的属性android:windowSoftInputMode =“adjustResize”将起作用。 如果您需要一个例子,请告诉我。

    <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">

        <LinearLayout
            android:id="@+id/middle"
            android:layout_width="10dip"
            android:layout_height="fill_parent"
            android:layout_centerVertical="true">
        </LinearLayout>

        <EditText 
              android:layout_above="@id/middle"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
        </EditText>

        <EditText
              android:layout_below="@id/middle"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent">
        </EditText>

    </RelativeLayout>
相关问题