Vista emergente de Android No funciona

Soy novato de android. Estoy tratando de implementar la ventana emergente desplazable en android.

Si hago la vista de desplazamiento En mi vista su muestra error ScrollView puede alojar solamente un niño directo (Detalles)

Aquí está mi código

private PopupWindow pwindo; private void initiatePopupWindow() { try { // We need to get the instance of the LayoutInflater LayoutInflater inflater = (LayoutInflater) About.this .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View layout = inflater.inflate(R.layout.screen_popup, (ViewGroup) findViewById(R.id.popup_element)); pwindo = new PopupWindow(layout,700,1000, true); // pwindo.showAtLocation(layout, Gravity.CENTER, 0, 0); // pwindo.showAsDropDown(layout, 80, 80); btnClosePopup = (Button) layout.findViewById(R.id.btn_close_popup); btnClosePopup.setOnClickListener(cancel_button_click_listener); } catch (Exception e) { e.printStackTrace(); } } private OnClickListener cancel_button_click_listener = new OnClickListener() { public void onClick(View v) { pwindo.dismiss(); } }; 

Y mi opinión

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/popup_element"> <TextView/> <TextView/> <TextView/> <ImageButton/> <ImageButton/> . . . . </ScrollView> 

Gracias por adelantado.

Tome Linear Layout como un padre:

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ScrollView android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/popup_element"> <TextView/> <TextView/> <TextView/> <ImageButton/> <ImageButton/> . . . . </ScrollView> </linearLayout> 

¡Aquí abajo debes hacerlo de esta manera!

 <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="fill_parent" android:orientation="vertical" android:id="@+id/popup_element"> <TextView/> <TextView/> <TextView/> <ImageButton/> <ImageButton/> . . . . </ScrollView> </LinearLayout> 

Coloque un LinearLayout dentro de ScrollView como debe colocar un niño en él que contiene todo el contenido para desplazarse; Este niño puede ser un gestor de diseño con una compleja jerarquía de objetos

El diseño debería verse así

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/popup_element"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical"> <TextView/> <TextView/> <TextView/> <ImageButton/> <ImageButton/> </LinearLayout> </ScrollView> 

Coloque todas las vistas dentro de LinearLayout y también dar poco menos de ancho y altura para la ventana emergente

 pwindo = new PopupWindow(layout,400,400, true); 

Esto puede ayudarle …

 <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" android:id="@+id/popup_element">> <LinearLayout android:id="@+id/child"> <TextView/> <TextView/> <TextView/> <ImageButton/> <ImageButton/> . . . . </LinearLayout> </ScrollView> 

Agregue LinearLayout como un hijo directo y coloque los otros controles en él.

  • ¿Cómo obtener vistas incluidas con Android Databinding?
  • El documento no tiene excepción de elemento raíz utilizando el serializador xml simple (v2.6.6)
  • ¿Cómo aplicar la validación del archivo DTD local al archivo xml en java?
  • Cómo configurar la pantalla completa de XML en Android
  • Los elementos de menú deben especificar un título
  • Android: Archivo XML de caché de RSS Feed
  • ¿Cómo agregar una vista de desplazamiento a toda una actividad?
  • ¿Cómo subraya un texto en android xml?
  • Mapbox infla la vista en el fragmento
  • Las etiquetas HTML no funcionan dentro de strings.xml
  • Android: Utilizar matriz de color en XML
  • FlipAndroid es un fan de Google para Android, Todo sobre Android Phones, Android Wear, Android Dev y Aplicaciones para Android Aplicaciones.