Android: Imagen de fondo redimensionar en pop-up de teclado

Estoy desarrollando una aplicación en la que la imagen de fondo se reduce en pop-up de teclado. Mi .xml es como sigue:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:facebook="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background" > <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > /** Other stuff */ </RelativeLayout> </ScrollView> </RelativeLayout> 

Busqué en Google y encontré que, para agregar

 android:windowSoftInputMode="stateVisible|adjustPan" 

En mi archivo de manifiesto. Pero es inútil.

Editar:

Mi diseño antes de que aparezca el teclado emergente se ve así:

Imagen 1

Y después de aparecer como:

Imagen 2

Compruebe la diferencia en la imagen de fondo. En imagen 1 la imagen está en tamaño y en imagen 2 imagen de fondo encogida. Necesito el pie de página y el fondo obtener desplazamiento hacia arriba en popup de teclado.

Lo que estoy perdiendo o haciendo mal, por favor, sugerirme.

Sólo use en su onCreate() este código:

 protected void onCreate(Bundle savedInstanceState) { ... getWindow().setBackgroundDrawableResource(R.drawable.your_image_resource); ... } 

Y eliminar esta línea en su xml:

 android:background="@drawable/background" 

Lee mas en:

http://developer.android.com/reference/android/view/Window.html

Ok si tengo tu pregunta correcta, quieres un diseño con un fondo y un scrollview. Y cuando aparece la softkey, desea cambiar el tamaño de la vista de desplazamiento, pero mantener el fondo en tamaño completo a la derecha? Si eso es lo que desea que pueda haber encontrado una solución para este problema:

Lo que puedes hacer es hacer 2 actividades.

Actividad 1:

 public class StartActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent StartApp = new Intent(this, DialogActivity.class); startActivity(StartApp); // Launch your official (dialog) Activity setContentView(R.layout.start); // your layout with only the background } } 

Actividad 2:

 public class DialogActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND); // get rid of dimming this.requestWindowFeature(Window.FEATURE_NO_TITLE); //get rid of title bar (if you want) setContentView(R.layout.dialog); //Dialog Layout with scrollview and stuff Drawable d = new ColorDrawable(Color.BLACK); //make dialog transparent d.setAlpha(0); getWindow().setBackgroundDrawable(d); } } 

Inicio de diseño

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/test"> //your background </LinearLayout> 

Diseño del diálogo:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent"> <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- All your Scrollview Items --> </LinearLayout> </ScrollView> </RelativeLayout> 

AndroidManifest.xml

Inicio Actividad:

 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> 

Dialog Actividad

 android:theme="@android:style/Theme.Dialog" android:windowSoftInputMode="adjustResize" android:excludeFromRecents="true" 

Editar: Para finalizar Actividades a la vez, utilice lo siguiente en algún lugar dentro de su DialogActivity (ejemplo: reemplaza el backbutton ):

 @Override public void onBackPressed() { Intent intent = new Intent(getApplicationContext(), StartActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("EXIT", true); startActivity(intent); } 

Y en onCreate() de StartActivity:

 if (getIntent().getBooleanExtra("EXIT", false)) { finish(); } else { Intent StartApp = new Intent(this, TestActivity.class); startActivity(StartApp); } 

Capturas de pantalla !

Normal Normal

Hizo clic en el cuadro EditarTexto Cuadro de texto

Después de Desplazado hacia abajo (ps: puse el cuadro de texto dentro de scrollview thats por qué se ha ido;)) Después de desplazarse hacia abajo

Espero que esto ayude a su salida;)

Yo había enfrentado el problema similar una vez, la mía se resolvió mediante el uso de las propiedades a continuación en el uso de manifiesto donde se declara su actividad.

  android:windowSoftInputMode="stateHidden|adjustResize|adjustPan" 

Hey, ¿puedes intentar agregar esto

 android:isScrollContainer="false" 

En su ScrollView . Ha resuelto mi problema una vez. Podría ayudarte también.

También, agregue esto a su actividad en manifest.xml

 android:windowSoftInputMode="adjustPan" 

Espero eso ayude..!! 🙂

Debes mover el android:background="@drawable/background" en un ImageView encima de ScrollView . Cuando el teclado aparece, efectivamente hace que la pantalla sea más pequeña, y tener una imagen como fondo no tiene control sobre cómo se redimensiona / recorta. Por lo tanto, suponiendo que desea tener la imagen de ancho completo, pero mantener la proporción de ascensión probar esto:

 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:facebook="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ImageView android:layout_width="fill_parent" android:layout_height="fill_parent" android:src="@drawable/background" android:scaleType="centerCrop" /> <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > /** Other stuff */ </RelativeLayout> </ScrollView> </RelativeLayout> 

Puede probar distintos valores de android:scaleType para lograr el efecto deseado. Si desea que la imagen se recorte de la parte superior en lugar del cultivo central predeterminado, consulte aquí cómo lograrlo o intente utilizar esta biblioteca

Compruebe esta respuesta , el truco básico es que no se establece el fondo para el diseño, sino a la ventana. Esto se puede hacer desde la actividad con getWindow().setBackgroundDrawable() , o puede configurarlo en un tema a su actividad.

En lugar de android:windowSoftInputMode="stateVisible|adjustPan" , debe cambiar a android:windowSoftInputMode="stateVisible|adjustResize" . Funcionó para mí.

Utilice ScrollView como principal superior. Se desplazará hacia arriba y hacia abajo automáticamente cuando abra y cierre el teclado.

¿Realmente necesita el RelativeLayout principal?

Porque si no lo hace, trate de usarlo así:

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" xmlns:facebook="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background" > <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" > /** Other stuff */ </RelativeLayout> </ScrollView> 

¿Por qué no te gusta esto?

  <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:fillViewport="true" android:focusable="true" android:background="@drawable/background" android:focusableInTouchMode="true"> <RelativeLayout android:id="@+id/relative" android:layout_width="fill_parent" android:layout_height="wrap_content" android:focusable="true" android:focusableInTouchMode="true" /** Other stuff */ > </RelativeLayout> </ScrollView> 

Estoy usando debajo de ver heirarchy y su funcionamiento muy bien para mí:

 <?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" > <ScrollView android:id="@+id/rfqItemsParentScrollView" android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > 
  • Relleno de ScrollView
  • ScrollView no se desplaza hasta el final del margen inferior del LinearLayout interno
  • ¿Cómo agregar una vista de desplazamiento a toda una actividad?
  • Android scrollview ocultando el contenido superior en el diseño
  • ScrollView no se desplaza. Desplazamiento lento
  • Cómo desplazamiento mediante programación de un ScrollView a inferior
  • Cargar más datos cuando ScrollView se desplaza hacia abajo
  • Android: ScrollView no se desplaza con el teclado fuera
  • CollapsingToolbarLayout ImageView no se puede desplazar
  • Android: el salto de Listview a scrollview
  • CardView Comportamiento de desplazamiento cuando el teclado está hacia arriba
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.