当我在点击EditText时候,屏幕会整体上移,但是屏幕中有一个webview的布局,还在原来的位置,并且会遮挡布局。而且webview布局里的内容还消失了,怎么解决webview的遮挡问题,还有webview的显示问题?
public class MainActivity extends Activity {
private WebView webView;
static final String mimeType = "text/html";
static final String encoding = "utf-8"; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
setContentView(R.layout.activity_main);
init();
} private void init() {
webView = (WebView) findViewById(R.id.social_list_feed_message_textview);
this.localHtmlZh();
// webViewFeed.setTextDirection(textDirection);
} private void localHtmlZh() {
try {
String data = "<html>在模拟器 2.1 上测试</html>";
// utf-8编码处理(在SDK1.5模拟器和真实设备上都将出现乱码,SDK1.6上能正常显示)
// MyWebView.loadData(data, mimeType, encoding);
// 对数据进行编码处理(SDK1.5版本)
webView.loadData(URLEncoder.encode(data, encoding), mimeType, encoding);
// MyWebView.loadDataWithBaseURL(null, data, mimeType, encoding, null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public boolean onTouchEvent(MotionEvent event) {
if(null != this.getCurrentFocus()){
/**
* 点击空白位置 隐藏软键盘
*/
InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
return mInputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
}
return super .onTouchEvent(event);
}
}
public class MainActivity extends Activity {
private WebView webView;
static final String mimeType = "text/html";
static final String encoding = "utf-8"; @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
setContentView(R.layout.activity_main);
init();
} private void init() {
webView = (WebView) findViewById(R.id.social_list_feed_message_textview);
this.localHtmlZh();
// webViewFeed.setTextDirection(textDirection);
} private void localHtmlZh() {
try {
String data = "<html>在模拟器 2.1 上测试</html>";
// utf-8编码处理(在SDK1.5模拟器和真实设备上都将出现乱码,SDK1.6上能正常显示)
// MyWebView.loadData(data, mimeType, encoding);
// 对数据进行编码处理(SDK1.5版本)
webView.loadData(URLEncoder.encode(data, encoding), mimeType, encoding);
// MyWebView.loadDataWithBaseURL(null, data, mimeType, encoding, null);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public boolean onTouchEvent(MotionEvent event) {
if(null != this.getCurrentFocus()){
/**
* 点击空白位置 隐藏软键盘
*/
InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
return mInputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
}
return super .onTouchEvent(event);
}
}
解决方案 »
- android手机用来开发3D游戏
- android 开发板如何识别有usb设备插入了
- 求教:支付宝客户端Android版的相对独立模块如何实现
- google Code 上的源码如何下载呢,DownLoad 选项卡里面都是jar文件,Source 选项卡里面只是一个无法打开的网址。
- 急求!!!bitmap拼接的问题
- 高手请帮帮忙啊
- android 用httpclient访问服务器不传参数直接传值如何写
- 程序中的图片占据大量内存,该如何处理
- jre路径问题还是api版本问题引起的?
- Android 功能实现问题
- android listview中checkbox控制点击数目。
- 使用getLastKnownLocation()来获取location值为空的问题
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.edittext.zedittext.MainActivity"
android:orientation="vertical"> <LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hi" />
<ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/hb_down"
/> <WebView
android:id="@+id/social_list_feed_message_textview"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:layout_marginTop="5dip"
/> <ImageView
android:layout_width="match_parent"
android:layout_height="200dp"
android:src="@drawable/hb_down"
/> <LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal"
android:gravity="center_vertical"
> <EditText
android:layout_width="0dp"
android:layout_height="50dp"
android:hint="请输入信息"
android:layout_weight="4"
/>
<Button
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="post"
></Button>
</LinearLayout>
</LinearLayout></ScrollView>就可以了