开发者

android edit text focus

i have two edit text on the layout and on load the cursor has to be on the second edit text. and how to move the edit text above the keypad on load. Re size property does not work. than开发者_运维技巧ks in advance


You can just add your layout in a scrollview, and it will automatically scroll up so the edittext be over the keyboard.


Use android:enabled=true in your editText. Use RelativeLayout to create your view and try not to give height of the editText directly. If you do so the property android:windowSoftInputMode="adjustResize" in your manifest will work. If you need an example just let me know.

    <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>


Use editText2.requestFocus(); to take cursor to 2nd EditText.And the EditText will move up automatically.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜