Cómo desplazar mi diseño al configurar android: windowSoftInputMode = "adjustPan"?
Mi actividad tiene una barra superior y una barra inferior. El espacio entre la barra superior y la barra inferior tengo un linearlayout con varias vistas edittext dentro. Porque no quiero que mi diseño cambie de tamaño cada vez que aparece el software, así que configuro android: windowSoftInputMode = "adjustPan" para mi actividad en manifesto. Pero cuando el softkeyboard está abierto, quiero desplazarse hacia abajo para seleccionar otro edittext a la entrada, no me permiten hacer eso. Im solamente capaz de seleccionar el edittext en la parte inferior cuando cierre el softkeyboard. Eso es muy molesto e inconveniente. ¿Cómo puedo obtener tanto el modo de desplazamiento como el modo de ajuste para el trabajo con el teclado virtual juntos?
Por favor, ayúdame. Muchas gracias.
- Estado lista estado desplegable y desactivado
- Cómo hacer aplicaciones hermosas y con estilo como Timely
- Android Studio - prestación de problemas de biblioteca de soporte
- Cómo escalar la imagen en Android CollapsingToolbarLayout como WunderList hace
- Ancho de TextView siguiente curva de ImageView
- ¿Hay una manera de aplicar esquinas redondeadas a un Mapfragment?
- Android Studio 2.0 (Vista previa 3b) xml cambios de diseño no se actualiza en apk?
- Tema diferente para diferentes versiones de SDK de Android
- Cómo agregar un atributo de tema a android: startColor en gradiente dibujable en Android?
- Cómo deshabilitar el clic de WebView?
- ¿Cómo mantener los atributos de diseño en la vista personalizada android combinada?
- Cómo animar los elementos de RecyclerView cuando aparecen
- Herencia de estilo en Android
Por fin, descubro una solución para mi problema, así que quiero compartir para alguien tal vez obtener el mismo problema en el futuro. Una breve descripción de mi diseño como sigue:
<myRelativeLayout> <topbar.../> <myscrollView> <linearLayout> //all stuff controls:editview,textview,.... </linearLayout> </myscrollView> <bottombar.../>
I crear la clase personalizada myRelativeLayout extend RelativeLayout
public class myRelativeLayout extends RelativeLayout{ public interface OnRelativeLayoutChangeListener { void onLayoutPushUp(); void onLayoutPushDown(); } private OnRelativeLayoutChangeListener layoutChangeListener; public myRelativeLayout(Context context, AttributeSet attrs) { super(context, attrs); // TODO Auto-generated constructor stub } @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { final int proposedheight = MeasureSpec.getSize(heightMeasureSpec); final int actualHeight = getHeight(); if (actualHeight > proposedheight){ // Keyboard is shown layoutChangeListener.onLayoutPushUp(); } else if(actualHeight < proposedheight){ // Keyboard is hidden layoutChangeListener.onLayoutPushDown(); } super.onMeasure(widthMeasureSpec, heightMeasureSpec); } public void setLayoutChangeListener(OnRelativeLayoutChangeListener layoutChangeListener) { this.layoutChangeListener = layoutChangeListener; } public OnRelativeLayoutChangeListener getLayoutChangeListener() { return layoutChangeListener; }
}
Y en mi actividad, sólo establecer setLayoutChangeListener para myRelativeLayout para ocultar bottombar cuando softkeyboard mostrar y mostrar bottombar cuando softkeyboard ocultar:
myRlayout.setLayoutChangeListener(new OnRelativeLayoutChangeListener() { @Override public void onLayoutPushUp() { // TODO Auto-generated method stub myBottombar.setVisibility(View.GONE);//in my case i need to setVisibility(View.GONE) to bottombar in order for this bar is not displayed when softkeyboard show up. } @Override public void onLayoutPushDown() { // TODO Auto-generated method stub myBottombar.setVisibility(View.VISIBLE);// redisplay myBottombar when keyboard is closed. } });
No olvide establecer android: windowSoftInputMode = "adjustResize" para la actividad. Espero que este útil para alguien tiene el mismo problema.
Poner los EditText
en un ScrollView
como este:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/scrollView1" android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:id="@+id/linearLayout1" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" > <requestFocus /> </EditText> <EditText android:id="@+id/editText2" android:layout_width="match_parent" android:layout_height="wrap_content" /> <EditText android:id="@+id/editText3" android:layout_width="match_parent" android:layout_height="wrap_content" /> </LinearLayout> </ScrollView>
- App Engine – RequestFactory vs servlets vs otros enfoques
- Diferencia entre Camera.translate y Matrix.preTranslate o Matrix.postTranslate?