原贴地址
http://www.eoeandroid.com/thread-53414-1-1.html
我的布局是这样的, 屏幕最上方 和屏幕最下方 各有一个edittext (输入框) ,我点击 屏幕下方的输入框 软键盘出来后 可以把最下面的输入框顶上去 ,但是我点击屏幕上方的输入框 软键盘不会把最下方的顶上去而是覆盖了最下方的输入框。我想要的是不管我点击上面的输入框 还是下面的输入框 出现软键盘后都会把 最下方的输入框顶上去、。 下面是我的xml 高手速来啊,,小弟在线等啊。。。55555555
< ?xml version="1.0" encoding="utf-8"?>
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
< ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button android:id="@+id/edit_button2"
android:layout_width="wrap_content"
android:layout_height="100px"
android:gravity="center"
android:layout_marginTop="370dip"
android:text="添加"
/>
<EditText android:id="@+id/edit_text1"
android:layout_width="200px"
android:layout_height="100px"
android:gravity = "top"
android:layout_toRightOf="@id/edit_button2"
android:hint="请输入信息内容"
android:layout_marginTop="370dip"
/>
<Button android:id="@+id/edit_button"
android:layout_width="wrap_content"
android:layout_height="100px"
android:layout_marginTop="370dip"
android:gravity="center"
android:layout_toRightOf="@id/edit_text1"
android:text="发送"
/>
</RelativeLayout>
</ScrollView>
<EditText android:id="@+id/edit_text"
android:layout_width="260px"
android:layout_height="wrap_content"
/>
<Button android:id="@+id/edit_button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/edit_text"
android:text="编辑"
/>
</RelativeLayout>
改了下你的布局:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button android:id="@+id/edit_button2" android:layout_width="wrap_content"
android:layout_height="100px" android:gravity="center"
android:text="添加" />
<EditText android:id="@+id/edit_text1" android:layout_width="200px"
android:layout_height="100px" android:gravity="top"
android:layout_toRightOf="@id/edit_button2" android:hint="请输入信息内容"
/>
<Button android:id="@+id/edit_button" android:layout_width="wrap_content"
android:layout_height="100px"
android:gravity="center" android:layout_toRightOf="@id/edit_text1"
android:text="发送" />
</RelativeLayout>
<EditText android:id="@+id/edit_text" android:layout_width="260px"
android:layout_height="wrap_content" />
<Button android:id="@+id/edit_button1" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_toRightOf="@id/edit_text"
android:text="编辑" />
</RelativeLayout>
然后在setconentView后面加这句话:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE |
WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);