2014-12-06 41 views
0

的我有四个的EditText在我的滚动视图以及一些复选框和按钮:键盘推我的EditText在屏幕

  • 姓氏
  • 电子邮件
  • 密码

    <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" > 
    
    <LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:orientation="vertical" > 
    
    <EditText 
        android:id="@+id/register_textedit_firstname" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="10dip" 
        android:ellipsize="end" 
        android:hint="@string/text_firstname" 
        android:inputType="text" 
        android:lines="1" 
        android:maxLines="1" 
        android:scrollHorizontally="true" 
        android:singleLine="true" /> 
    
    <EditText 
        android:id="@+id/register_textedit_lastname" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="10dip" 
        android:ellipsize="end" 
        android:hint="@string/text_lastname" 
        android:inputType="text" 
        android:lines="1" 
        android:maxLines="1" 
        android:scrollHorizontally="true" 
        android:singleLine="true" /> 
    
    <EditText 
        android:id="@+id/register_textedit_email" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="10dip" 
        android:ellipsize="end" 
        android:hint="@string/text_email" 
        android:inputType="textEmailAddress" 
        android:lines="1" 
        android:maxLines="1" 
        android:scrollHorizontally="true" 
        android:singleLine="true" /> 
    
    <EditText 
        android:id="@+id/register_textedit_password" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginBottom="10dip" 
        android:ellipsize="end" 
        android:hint="@string/text_password" 
        android:inputType="textPassword" 
        android:lines="1" 
        android:maxLines="1" 
        android:scrollHorizontally="true" 
        android:singleLine="true" /> 
    
    <CheckBox 
        android:id="@+id/register_checkbox_password" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/checkbox_showpassword" /> 
    
    <LinearLayout 
        style="?android:attr/buttonBarStyle" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:orientation="horizontal" > 
    
        <Button 
         android:id="@+id/register_button_register" 
         style="?android:attr/buttonBarButtonStyle" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:text="@string/button_register" /> 
    
        <Button 
         android:id="@+id/register_button_cancel" 
         style="?android:attr/buttonBarButtonStyle" 
         android:layout_width="0dp" 
         android:layout_height="wrap_content" 
         android:layout_weight="1" 
         android:text="@string/button_cancel" /> 
        </LinearLayout> 
    </LinearLayout> 
    
    </ScrollView> 
    

这项活动的清单:

<activity 
     android:name="de.hof.ime_dc.idia_move.activities.RegisterActivity" 
     android:label="@string/title_activity_register" 
     android:launchMode="singleTask" > 
    </activity> 

在i集中姓名或LASTNAME所述的EditText为姓名被压出的顶层画面的。我无法看到它,但我可以输入它。当我专注于电子邮件或密码时,EditText的名字会回到屏幕中。我不能理解这个行为,因为当名字EditText被推出屏幕我不能滚动到它(他们都在一个滚动查看)。

不要误会我的意思,我希望我的意见能够在键盘出现时被推高,但我不希望它们被推出屏幕而不能滚动到它们。

编辑

只是一个想法:

也许是因为我的行动标题栏的?在每个屏幕上,我都有一个带导航抽屉的动作标题栏。它似乎edittext被推到标题栏下。那可能吗?

EDIT 2

我注意到,它恰好Android设备上使用Android 5.0版的。 一个错误?

+0

显示您的AndroidManifest.xml也适用于此活动。更新了 – VicJordan 2014-12-06 11:31:32

+0

。这里没有什么特别的。我不添加ajustPan,因为就像我写的,我希望视图被推高。 – Mulgard 2014-12-06 11:36:21

回答

0

您可以添加“adjustResize”你的清单文件,以解决此类错误的 -

<application ... > 
    <activity 
     android:windowSoftInputMode="adjustResize" ... > 
     ... 
    </activity> 
    ... 
</application> 

希望这有助于你:)

+0

不幸'android:windowSoftInputMode =“adjustResize”'不会改变任何东西。 – Mulgard 2014-12-06 12:29:00

1

就在您的Manifest。它添加这个工作对我来说

android:windowSoftInputMode="stateAlwaysHidden|adjustPan" 

我检查这个,请您及时添加此

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" > 

欲了解更多信息,你可以看到这LINK

+1

不,这也不起作用,因为就像我写的那样,如果键盘不适合,我希望视图被推高。如果我设置adjustPan而不是键盘隐藏字段。 – Mulgard 2014-12-06 12:50:45

+0

@Mulgard请检查我的答案。 – 2014-12-06 13:26:56

+0

它不适合我。当我添加它时,视图不会再被推高。和fill_parent是顺便说一句。弃用。 – Mulgard 2014-12-06 15:26:59

0

的问题是,我已将此添加到我的布局:

android:layout_gravity="center" 

那是罪恶的根源。

+0

哦。那种情况。迈向未来。 – 2016-01-27 08:06:08