按钮自带键盘我该如何修复
button comes with keyboard how can i fix
我使用了 scrollView 并且 scrollView 外部只有一个按钮,但是当我在 scrollVIew 内部输入编辑文本时,按钮随键盘一起出现,我该如何解决这个问题
<LinearLayout>
......
......
......
<ScrollView>
......
<EditText>....1
<EditText>....2
<EditText>....3
<EditText>....4
<EditText>....5
<EditText>....6
<EditText>....7
<EditText>....8
</ScrollView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_margin="5dp"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/step1_button_submit"
style="@style/buttonStyle.RoundCorner.Red.20sp"
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:text="@string/save" />
</RelativeLayout>
</LinearLayout>
尝试将键盘更改为平移而不是调整大小。您可以在 AndroidManifest.xml 文件中为您的特定 activity 添加以下内容
android:windowSoftInputMode="adjustPan"
如果你想隐藏那么:
EditText editTextSearch = (EditText) findViewById(R.id.editTextSearch);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextSearch.getWindowToken(), 0);
如果要显示:
EditText editTextSearch = (EditText) findViewById(R.id.editTextSearch);
editTextSearch.requestFocus();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
我使用了 scrollView 并且 scrollView 外部只有一个按钮,但是当我在 scrollVIew 内部输入编辑文本时,按钮随键盘一起出现,我该如何解决这个问题
<LinearLayout>
......
......
......
<ScrollView>
......
<EditText>....1
<EditText>....2
<EditText>....3
<EditText>....4
<EditText>....5
<EditText>....6
<EditText>....7
<EditText>....8
</ScrollView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:layout_margin="5dp"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/step1_button_submit"
style="@style/buttonStyle.RoundCorner.Red.20sp"
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_height="wrap_content"
android:text="@string/save" />
</RelativeLayout>
</LinearLayout>
尝试将键盘更改为平移而不是调整大小。您可以在 AndroidManifest.xml 文件中为您的特定 activity 添加以下内容
android:windowSoftInputMode="adjustPan"
如果你想隐藏那么:
EditText editTextSearch = (EditText) findViewById(R.id.editTextSearch);
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(editTextSearch.getWindowToken(), 0);
如果要显示:
EditText editTextSearch = (EditText) findViewById(R.id.editTextSearch);
editTextSearch.requestFocus();
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);