触摸编辑时,Android键盘视图位于编辑文本的前面
在图1中,我有一个带有一些textview和edittext控件的布局,当用户触摸此特定布局的任何edittext(其他活动没有此问题)时,键盘出现在edittext控件前面,因此用户看不到他在写什么,这很奇怪,图2显示了问题。以下是我的XML:触摸编辑时,Android键盘视图位于编辑文本的前面,android,android-edittext,keypad,Android,Android Edittext,Keypad,在图1中,我有一个带有一些textview和edittext控件的布局,当用户触摸此特定布局的任何edittext(其他活动没有此问题)时,键盘出现在edittext控件前面,因此用户看不到他在写什么,这很奇怪,图2显示了问题。以下是我的XML: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<EditText
android:id="@+id/responsavelContratadaDiarioEditar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/TextView71"
android:layout_marginBottom="10dp"
android:ems="10"
android:imeOptions="actionDone"
android:singleLine="true" >
<requestFocus />
</EditText>
<Button
android:id="@+id/dataVistoriaDiarioEditar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/responsavelContratadaDiarioEditar"
android:text="Data da Vistoria" />
<TextView
android:id="@+id/TextView81"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/dataVistoriaDiarioEditarTexto"
android:text="Ponto de Controle"
android:textSize="18sp"
android:textStyle="bold" />
<EditText
android:id="@+id/pontoControleDiarioEditar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_below="@+id/TextView81"
android:layout_weight="0.56"
android:ems="10"
android:gravity="top"
android:imeOptions="actionDone"
android:inputType="textMultiLine"
android:maxLines="10"
android:scrollbars="vertical"
android:singleLine="false" />
<TextView
android:id="@+id/TextView71"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/projeto_spinnerDiarioEditar"
android:text="Responsável contratada"
android:textSize="18sp"
android:textStyle="bold" />
<Spinner
android:id="@+id/projeto_spinnerDiarioEditar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView11"
android:spinnerMode="dialog" />
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:text="Projeto"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="@+id/dataVistoriaDiarioEditarTexto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/dataVistoriaDiarioEditar"
android:layout_toRightOf="@+id/dataVistoriaDiarioEditar"
android:clickable="false"
android:text="23/12/1989" />
</RelativeLayout>
</LinearLayout>
谢谢。在清单文件中的
下使用以下属性:
在您的清单文件中使用该活动名称下的任何内容
在setContentView之后,我在onCreate()方法中添加了这段代码,它成功了:)
谢谢。@crawletas您也尝试过“调整大小”吗?或者你可能需要这两个“调整幅度”。可能的“Stuu”副本没有一个来自这个主题的答案帮助了你。然后,你可能想考虑一下你能做些什么来让你的布局按照你的意愿工作。首先,我想问,当你只有一个孩子的时候,为什么你需要线性布局和相对布局?在父布局中创建RelativeLayout,然后重试这些解决方案。有人给了你一个有效的答案,然后你创建了自己的答案,并将其作为有效答案接受。。。
android:windowSoftInputMode="adjustPan"
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);