2014-07-02 79 views
2

已经搜索了很多,但无法找到一个令人满意的解决方案。下面的截图描述了我正面临的问题。edittext隐藏在标题栏当软键盘可见

enter image description here

EDITTEXT背后隐藏标题栏时,软键盘是可见的。我已经把

android:gravity="center_vertical" 

属性在主布局。如果我删除此属性,布局工作fine.But设计要求所需要的形式是在center.I使用everything.Tried滚动视图并投入清单

android:windowSoftInputMode="stateVisible|adjustResize" 

这也尝试过“adjustPan”,并试图它确实有用。但是在这种情况下,整个表单不会被推高。编辑文本'MobileNo'并且按钮保持隐藏在软键盘后面。

布局XML代码:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" 
android:gravity="center_vertical" 
android:padding="5dp"> 


    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="324dp" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="10dp" 
     android:background="#39CCCCCC" 
     android:orientation="vertical" 
     android:isScrollContainer="true" 
     android:padding="5dp" 
     > 

    <EditText android:id="@+id/edit_name" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/edittext_dimen" 
     android:hint="@string/register_name" 
     android:textColor="@color/black" 
     android:textSize="20sp" 
android:background="@drawable/rounded_edittext_bg" 
     android:layout_marginRight="5dp" 
    android:layout_marginLeft="5dp" 
     android:layout_marginTop="20dp" 
     android:padding="5dp" 
     android:inputType="textPersonName"/> 

<EditText android:id="@+id/edit_email" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/edittext_dimen" 
     android:hint="@string/register_emailid" 
     android:textColor="@color/black" 
     android:textSize="20sp" 
android:background="@drawable/rounded_edittext_bg" 
     android:layout_marginRight="5dp" 
    android:layout_marginLeft="5dp" 
     android:layout_marginTop="5dp" 
     android:padding="5dp" 
     android:inputType="textEmailAddress" /> 

<EditText android:id="@+id/edit_password" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/edittext_dimen" 
     android:hint="@string/register_pass_hint" 
     android:textColor="@color/black" 
     android:textSize="20sp" 
android:background="@drawable/rounded_edittext_bg" 
     android:layout_marginRight="5dp" 
    android:layout_marginLeft="5dp" 
     android:layout_marginTop="5dp" 
     android:padding="5dp" 
     android:inputType="textPassword" /> 

<EditText android:id="@+id/edit_confpassword" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/edittext_dimen" 
     android:hint="@string/register_confpass" 
     android:textColor="@color/black" 
     android:textSize="20sp" 
android:background="@drawable/rounded_edittext_bg" 
     android:layout_marginRight="5dp" 
    android:layout_marginLeft="5dp" 
     android:layout_marginTop="5dp" 
     android:padding="5dp" 
     android:inputType="textPassword" /> 

<EditText android:id="@+id/edit_mobile" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/edittext_dimen" 
     android:hint="@string/register_mobile" 
     android:textColor="@color/black" 
     android:textSize="20sp" 
android:background="@drawable/rounded_edittext_bg" 
     android:layout_marginRight="5dp" 
    android:layout_marginLeft="5dp" 
     android:layout_marginTop="5dp" 
     android:padding="5dp" 
     android:maxLength="11" 
     android:inputType="phone"/> 



<Button android:id="@+id/signup_btn" 
     android:layout_width="match_parent" 
     android:layout_height="@dimen/edittext_dimen" 
     android:layout_marginTop="5dp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_gravity="center_horizontal" 
     android:text="@string/register_signup" 
     android:textSize="20sp" 
     android:background="#3F799F" 
     android:textColor="@color/white"/> 
</LinearLayout> 
</LinearLayout> 

对此有任何解决方案?任何可以帮助我实现目标的解决方法?请回复您的意见和建议。

如果您无法理解我的疑问,请随时提问。 预先感谢您。

+0

它,因为你必须使用相对布局。我可能是错的,但是你已经给出了按钮以实现底部真实,以及按钮上方的其他关系。发布清除IDEA的XML文件。 –

+0

当键盘出现时,您唯一能掌握的就是软输入模式,唯一的选择是平移和调整大小。您可能会对布局进行更改以改善内容,但键盘没有设置可以解决问题。 –

+0

http://android-developers.blogspot.in/2009/04/updating-applications-for-on-screen.html –

回答

3

我解释一下你的错误。当键盘打开“线性布局”需要屏幕上有足够的空间以使其上升并且不可见时,您已将衬里布局设置为324dp .so。您的第一个编辑文本。

改为使用相对布局。

等一下我给你修改的XML。直到时间检查你的XML

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/RelativeLayout1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:gravity="center_vertical" 
android:orientation="vertical" 
android:padding="5dp" > 

<LinearLayout 
    android:id="@+id/LinearLayout1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
    android:background="#39CCCCCC" 
    android:isScrollContainer="true" 
    android:orientation="vertical" 
    android:padding="5dp" > 

    <EditText 
     android:id="@+id/edit_name" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="20dp" 
     android:hint="Name" 
     android:inputType="textPersonName" 
     android:padding="5dp" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <EditText 
     android:id="@+id/edit_email" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="5dp" 
     android:hint="Email" 
     android:inputType="textEmailAddress" 
     android:padding="5dp" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <EditText 
     android:id="@+id/edit_password" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="5dp" 
     android:hint="password" 
     android:inputType="textPassword" 
     android:padding="5dp" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <EditText 
     android:id="@+id/edit_confpassword" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="5dp" 
     android:hint="Confirm password" 
     android:inputType="textPassword" 
     android:padding="5dp" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <EditText 
     android:id="@+id/edit_mobile" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="5dp" 
     android:hint="register" 
     android:inputType="phone" 
     android:maxLength="11" 
     android:padding="5dp" 
     android:textColor="#000" 
     android:textSize="20sp" /> 

    <Button 
     android:id="@+id/signup_btn" 
     android:layout_width="match_parent" 
     android:layout_height="30dp" 
     android:layout_gravity="center_horizontal" 
     android:layout_marginLeft="5dp" 
     android:layout_marginRight="5dp" 
     android:layout_marginTop="5dp" 
     android:background="#3F799F" 
     android:text="signup" 
     android:textColor="#fff" 
     android:textSize="20sp" /> 
</LinearLayout> 

</RelativeLayout> 

活动代码清单中写这个android:windowSoftInputMode="adjustResize|adjustPan"

我改变你的渔政船,大小,颜色也字符串resourch

+0

是的,如果我设置linearlayout的高度来包装内容.. edittext不隐藏在标题栏后面,但然后手机号码和注册按钮隐藏在softkeyboard后面,它甚至不会在键盘可见时滚动。我希望用户应该能够滚动,直到注册按钮,即使键盘激活 –

+0

嘿thanx ..问题已解决..我改变了linearlayout的高度来包装内容,如你所说,并把它放在scrollview中,并提到这在manisfest android:windowSoftInputMode =“stateVisible | adjustResize” ..即使主布局是LinearLayout.Thanx,也是如此。:) –

+0

您的Wellcome狐狸。 –

1

在清单中添加adjustPanactivity标签

android:windowSoftInputMode="adjustResize|adjustPan"