Android 点击EditText focus 不在键盘之上时

Android ScrollView 在安卓系统里是自带寻找光标到软键盘的上面的 。。 

但是有时候是找不到的 

原因在于ScrollView没有拿到全部的高度

即等于    android:layout_height="fill_parent" 

在ScrollView 的上面或者下面只要穿插了一个widget都不会自动去寻找

 

所以这个时候 只要把 最上位的 Xml Tag 设置成 RelativLayout 就可以了 

比如

<?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" 
android:orientation="vertical" > 
<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_marginTop="10dp" 
android:textColor="#ffffff" 
android:text="HEADER TEST" 
android:textSize="20dp" /> 
<LinearLayout 
android:layout_marginTop="50dp" 
android:layout_width="fill_parent" 
android:layout_height="380dp" > 
<ScrollView 
android:id="@+id/scrollview" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"> 
<LinearLayout 
android:layout_width="fill_parent" 
android:layout_height="400dp" 
android:orientation="vertical" > 
<EditText 
android:text="1" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 
<EditText 
android:text="2" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

<EditText 
android:text="3" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

<EditText 
android:text="4" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

<EditText 
android:text="5" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

<EditText 
android:text="6" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

<EditText 
android:text="7" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

<EditText 
android:text="8" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

<EditText 
android:text="9" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

<EditText 
android:text="10" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

<EditText 
android:text="11" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 
<EditText 
android:text="12" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 
<EditText 
android:text="13" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 
<EditText 
android:text="Over" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" /> 

</LinearLayout> 
</ScrollView> 
</LinearLayout> 

<TextView 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:layout_marginTop="460dp" 
android:textSize="20dp" 
android:textColor="#ffffff" 
android:text="FOOTER TEST" /> 

</RelativeLayout>

 

 

我只用了 Xml来 处理了 这个事件  

希望能得到点帮助。。。 

 

把main的code 改了 试试看吧 。。。 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值