El teclado Android se esconde EditText
Cuando intento escribir algo en un EditText que está en la parte inferior de la pantalla, el teclado virtual oculta editText. ¿Cómo puedo resolver este problema? A continuación está mi código xml. Estoy usando esta pantalla en Fragmento.
<ScrollView 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="fill_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id/linearLayoutTopDetails" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/linearLayoutTop" android:layout_marginLeft="6dp" android:layout_marginRight="6dp" android:layout_marginTop="6dp" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/list_design1" android:orientation="vertical" > <LinearLayout android:layout_width="fill_parent" android:layout_height="80dp" android:layout_weight="100" android:orientation="horizontal" > <ImageView android:id="@+id/ImageViewProfImagePostDetail" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_marginTop="2dp" android:layout_weight="24.84" android:paddingLeft="5dp" android:paddingRight="5dp" android:paddingTop="5dp" /> <LinearLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="60" android:orientation="vertical" > <TextView android:id="@+id/textViewNamePostDetail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Robin" android:textSize="17sp" /> <TextView android:id="@+id/textViewLocationPostDetail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginTop="1dp" android:drawableLeft="@drawable/location" android:text="beijing, China" /> <TextView android:id="@+id/textViewTimeAgoPostDetail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=" 18min ago" /> </LinearLayout> <LinearLayout android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="15" android:orientation="horizontal" > <TextView android:id="@+id/textViewReportAbusePostDetail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:background="@drawable/flag" android:paddingLeft="5dp" /> <TextView android:id="@+id/textViewDeletePostDetail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_marginLeft="15dp" android:background="@drawable/delete" android:visibility="gone" /> </LinearLayout> </LinearLayout> <TextView android:id="@+id/textViewDescriptionPostDetail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="20dp" android:layout_marginTop="2dp" android:singleLine="false" android:text="Description or caption of the post" android:textSize="17sp" /> </LinearLayout> <ImageView android:id="@+id/feedPostedImagePostDetail" android:layout_width="fill_parent" android:layout_height="200dp" android:layout_marginTop="5dp" android:scaleType="fitCenter" android:visibility="gone" /> <LinearLayout android:id="@+id/linearLayoutOptions" android:layout_width="fill_parent" android:layout_height="33dp" android:layout_marginTop="2dp" android:layout_weight="100" android:background="@drawable/bar" android:orientation="horizontal" > <TextView android:id="@+id/textViewShakePostDetail" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_marginLeft="15dp" android:layout_weight="25" android:drawableLeft="@drawable/like" android:gravity="center" android:singleLine="true" android:text="Shake" android:textSize="12sp" /> <TextView android:id="@+id/textViewCommentPostDetail" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="41" android:drawableLeft="@drawable/comment" android:gravity="center" android:paddingLeft="20dp" android:text="Comment" /> <TextView android:id="@+id/textViewSharePostDetail" android:layout_width="0dp" android:layout_height="fill_parent" android:layout_weight="33" android:drawableLeft="@drawable/share" android:gravity="center" android:paddingLeft="20dp" android:text="Spread" /> </LinearLayout> </LinearLayout> <ListView android:id="@+id/listViewFeedsDetail1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/linearLayoutTopDetails" android:layout_marginBottom="4dp" android:layout_marginLeft="6dp" android:layout_marginRight="6dp" android:layout_marginTop="6dp" > </ListView> <LinearLayout android:id="@+id/linearLayoutPostcomment" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="@+id/listViewFeedsDetail1" android:background="#FFFFFF" android:orientation="horizontal" android:weightSum="100" > <EditText android:id="@+id/editTextComment" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="80" /> <Button android:id="@+id/buttonPostComment" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="20" android:background="#F0F8FF" android:text="Post" > </Button> </LinearLayout> </RelativeLayout> </ScrollView>
“
- Desplácese la página cuando el teclado suaves aparece
- Controlar los botones Ok SoftKeyboard Android
- Mostrar teclado suave (numérico) usando AlertDialog.Builder
- Teclado Android Entrar / Siguiente Button handler
- Obtener la posición del cursor en Android en Editar texto?
He intentado resolver este problema añadiendo cambios a través del código, pero sin éxito.
A continuación se muestra la imagen antes y después de hacer clic en EditText.
- Mostrar teclado virtual en android TabLayout
- ¿Cómo abrir el teclado numérico cuando haga clic en EditText?
- Anulación del botón de menú físico en android
- Ajusta scrollview cuando el teclado está hacia arriba
- ¿Hay alguna manera en Android de saber si un dispositivo de los usuarios tiene un teclado real o no?
- Problema con el teclado al enfocar el texto de edición de fondo en Android
- ¿Cómo hacer que una vista de Android se desplace cuando aparece el teclado?
- Interceptar el botón de menú de Android en un PopupWindow
En su manifiesto ponga esto en su actividad perticular:
android:windowSoftInputMode="adjustPan"
Para eso tienes que declarar en tu actividad manifeast
<activity android:name=".activityname" android:label="@string/app_name" android:windowSoftInputMode="adjustPan|adjustResize" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
Utilice el siguiente código donde:
InputMethodManager ipmm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); ipmm.hideSoftInputFromWindow(url.getWindowToken(), 0);
Donde url en mi código es:
url = (EditText) findViewById(R.id.eT_webbrowser);
O Intente esto:
InputMethodManager ipmm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); ipmm.hideSoftInputFromWindow(null, 0);
Como otra opción, intente esto: Esto siempre oculta el modo de entrada suave de modo que su EditText sea visible
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Declare windowSoftInputMode = "adjustResize" en el archivo manifest.xml
<activity android:name=".example" android:theme="@style/AppTheme.NoActionBar" android:windowSoftInputMode="adjustResize" />
Proporcione la vista de desplazamiento al archivo de diseño xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingBottom="16dp" android:paddingLeft="16dp" android:paddingRight="16dp" android:paddingTop="16dp" android:fitsSystemWindows="true"> <ScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:fillViewport="true" android:isScrollContainer="false"> // add edittext here... </ScrollView> </RelativeLayout>
Esto parece ser un error en android cuando se adjustPan
modo adjustPan
Pruebe este Custom EditText
con solución para este problema
https://gist.github.com/Arjun-sna/768de4ca141798c59a8166a2e5d4a743
Aquí hay una solución sencilla para Android EditarText cuestión de ocultar detrás de SoftKeypad . Utilice el código en el archivo AndroidManifest.xml del módulo de proyecto.
<activity android:name="com.example.MainActivity" android:label="@string/activity_main" android:windowSoftInputMode="adjustResize|stateHidden" />
Este código funcionó para mí.
Dentro del archivo de manifiesto en la etiqueta de actividad, añada este atributo:
android:windowSoftInputMode="adjustResize|stateHidden"
Hay más valores para este atributo ( android:windowSoftInputMode
) que vendrá como lista de recomendaciones. Usted puede comprobar con ellos también.