2012-05-08 44 views
3

我正在使用此登录屏幕,并且希望在显示IME时调整所有字段,文本和按钮的大小。我已经在androidManifest.xml中使用了android:windowSoftInputMode =“adjustResize”,但我仍然在其他人的下面找到了一些元素。如何在显示软键盘时保持所有字段和文本可见

如果TextView“Cadastre Agora”(id = cadastrar)仍然被虚拟键盘所覆盖,我无所谓。但是,只要有几个元素,我试图至少使EditTexts(和他们的TextViews)和按钮可见。

我发现这个没有答案的问题,可能是一个有趣的方法:HTTP://stackoverflow.com/问题/ 6484024 /软键盘保持一视后的固定而移动的,其他

感谢帮助!

屏幕无IME:http://imageshack.us/photo/my-images/138/semttulo2mr.png/

屏幕与IME(TextView1被隐藏起来):http://imageshack.us/photo/my-images/404/semttulo3xw.png/

#2抱怨我的代码的格式,所以我在这里上传的xml文件:HTTPS://rapidshare.com /files/1767398103/login.xml 我不能发布超过2个链接,这就是为什么我会在其中放置空格。

回答

2

在这种情况下,我会说你的初始布局(没有键盘显示)已经有问题了。鉴于您正在创建纯粹是登录屏幕的内容,将所有控件放置在屏幕的上半部分并在用户访问该页面时自动显示键盘是可以接受的。这使得用户的体验更加快速,并且节省了您必须提供灵活的布局。

但是,如果您想尝试在两个视图中使布局工作,则需要将控件之间的间距更改为动态。

例如:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width = "fill_parent" 
    android:layout_height = "fill_parent" 
    android:orientation="vertical" 
    > 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
     <!-- Username Controls here --> 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
     <!-- Password Controls here --> 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
     <!-- Login Button here --> 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
     <!-- TextView here --> 
    <Space 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="1"> 
</LinearLayout> 

为了这个正常工作,所有的垂直填补必须从控制拆下,用标签的文本框之间填充的除外。

+0

使用如此多的'LinearLayout'对于性能来说**性能差。 @Lucas,请尝试检查[Android IME选项](http://developer.android.com/resources/articles/on-screen-inputs.html) – thepoosh

+0

确实,它可能会像简单的View对象一样正常工作。 – Scott

+0

这对我有用:D我在下面粘贴了我的代码。谢谢@Scott。 –

相关问题