---
title: "软键盘弹出挤压画面的问题"
author: "ableouou"
date: "2011-06-28T10:19:45Z"
tags: []
categories: ["移动开发"]
slug: "untitled"
draft: false
lastmod: "2011-06-28T10:23:37Z"
id: 1107324
url: "https://ableouou.iteye.com/blog/1107324"
---

情况，在页面的下方有一排按钮，上面分别是textview，listview：代码如下：
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:layout_height="match_parent" android:layout_width="match_parent"
	android:background="@drawable/blacklist_spam_bg" android:orientation="vertical">




	<TextView android:id="@+id/TextView01" android:layout_height="38dip"
		android:background="@drawable/blacklist_spam_title" android:gravity="center_vertical"
		android:layout_width="match_parent" android:text="@string/able_blacklist_title_spam"
		android:textSize="18sp" android:textColor="#ff000000"></TextView>
	<LinearLayout android:id="@+id/LinearLayout01"
		android:layout_width="match_parent" android:layout_height="370dip">
		<ListView android:layout_width="match_parent"
			android:layout_height="wrap_content" android:id="@+id/lv_spam_number"
			android:background="#ffffffff" android:cacheColorHint="#00000000"></ListView>
	</LinearLayout>


	<LinearLayout android:id="@+id/LinearLayout02"
		android:layout_height="wrap_content" android:layout_marginTop="5dip"
		android:layout_width="match_parent">
		<Button android:layout_marginLeft="8dip" android:layout_width="86dip"
			android:id="@+id/btn_spam_add" android:background="@drawable/blacklist_spam_add_effect"
			android:layout_height="41dip"></Button>
		<Button android:id="@+id/btn_spam_import" android:layout_width="86dip"
			android:layout_height="41dip" android:layout_marginLeft="18dip"
			android:background="@drawable/blacklist_spam_import_effect"></Button>
		<Button android:layout_marginLeft="18dip" android:layout_width="86dip"
			android:id="@+id/btn_spam_delete_all" android:background="@drawable/blacklist_spam_delete_all_effect"
			android:layout_height="41dip"></Button>

	</LinearLayout>
</LinearLayout>


并且我们设置该activity的属性为：android:windowSoftInputMode="adjustPan"
存在问题，长按menu时，会弹出软键盘，并且，在listview中的第6第7项也就是接近软键盘弹出的上边缘的时候会存在抖动问题。

解决方法：把 activity的属性设置为：android:windowSoftInputMode="stateHidden|adjustResize" OK

附上说明：

"stateUnspecified"

软键盘的状态 (是否它是隐藏或可见 )没有被指定。系统将选择一个合适的状态或依赖于主题的设置。

这个是为了软件盘行为默认的设置。

"stateUnchanged"

软键盘被保持无论它上次是什么状态，是否可见或隐藏，当主窗口出现在前面时。

"stateHidden"

当用户选择该 Activity时，软键盘被隐藏——也就是，当用户确定导航到该 Activity时，而不是返回到它由于离开另一个 Activity。

"stateAlwaysHidden"

软键盘总是被隐藏的，当该 Activity主窗口获取焦点时。

"stateVisible"

软键盘是可见的，当那个是正常合适的时 (当用户导航到 Activity主窗口时 )。

"stateAlwaysVisible"

当用户选择这个 Activity时，软键盘是可见的——也就是，也就是，当用户确定导航到该 Activity时，而不是返回到它由于离开另一个 Activity。

"adjustUnspecified"

它不被指定是否该 Activity主 窗口调整大小以便留出软键盘的空间，或是否窗口上的内容得到屏幕上当前的焦点是可见的。系统将自动选择这些模式中一种主要依赖于是否窗口的内容有任何布局 视图能够滚动他们的内容。如果有这样的一个视图，这个窗口将调整大小，这样的假设可以使滚动窗口的内容在一个较小的区域中可见的。这个是主窗口默认的行为 设置。

"adjustResize"

该 Activity主窗口总是被调整屏幕的大小以便留出软键盘的空间

"adjustPan"

该 Activity主窗口并不调整屏幕的大小以便留出软键盘的空间。相反，当前窗口的内容将自动移动以便当前焦点从不被键盘覆盖和用户能总是看到输入内容的部分。这个通常是不期望比调整大小，因为用户可能关闭软键盘以便获得与被覆盖内容的交互操作。