开发者

Android Custom EditText is resized by keyboard open and close

i implemented a custom background for my EditText fields because i think the defaults for the EditTexts are too tall & have too much padding. anyway, the new EditText drawable backgrounds are displaying fine, BUT the fields shrink slightly when i open the keyboard and expand to their original (custom) size when i close the keyboard. this behavior must be overridable in some way that i just haven't stumbled across. can anyone help, please? I've read the IMEOptions article at the dev android site and nothing there really jumps out at me at as a possible solution to this problem. thanks!

here is my EditText - each EditText is in its own layout because i needed to add padding BETWEEN the fields:

<LinearLayout android:layout_height="wrap_content"
        android:layout_width="fill_parent" android:orientation="vertical" android:paddingBottom="5dip" android:paddingLeft="3dip"  android:paddingRight="3dip">
        <EditText android:id="@+id/join_firstName"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:background="@drawable/joinedittextselector" android:padding="5dip" />  <!-- android:layout_weight="1" -->
    </LinearLayout>

here is my selector:

<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_window_focused="false" android:state_enabled="true"
    android:draw开发者_如何学Goable="@drawable/join_field_bg_default" />
<item android:state_window_focused="false" android:state_enabled="false"
    android:drawable="@drawable/join_field_bg_default" />
<item android:state_pressed="true" android:drawable="@drawable/join_field_bg_default" />
<item android:state_enabled="true" android:state_focused="true"
    android:drawable="@drawable/join_field_bg_selected" />
<item android:state_enabled="true" android:drawable="@drawable/join_field_bg_default" />
<item android:state_focused="true" android:drawable="@drawable/join_field_bg_selected" />
<item android:drawable="@drawable/join_field_bg_default" />

i've tried adjustResize and adjustPan for the android:windowSoftInputMode setting of the activity that the EditText is used in and neither have worked. thanks again for any advice on this!


You would probably have to provide images for the various states defining them in an xml resource. People do this a lot for buttons.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜