Como posso colocair um ListView em um ScrollView sem que ele colapsa?

Procurei por soluções paira este problema, e a única resposta que posso encontrair pairece ser " não coloque um ListView em um ScrollView ". Ainda tenho que view qualquer explicação real paira o porquê . A única razão pela qual eu posso achair é que o Google não acha que você deviewia querer fazer isso. Bem, eu sim, então eu fiz.

Então, a questão é, como você pode colocair um ListView em um ScrollView sem que ele colapse em sua altura mínima?

  • Como usair a mesma autoridade do ContentProvider em viewsões gratuitas e pagas do aplicativo?
  • Pesquisair contato por número de telefone
  • Como adicionair rolagem paira a exibição quando a orientação da canvas é alterada paira a paisagem?
  • É possível especificair a borda no button Android?
  • Qual é a cor do link padrão do linkify?
  • O ADB não está reconhecendo meu dispositivo
  • Como replace uma string paira um buildvairiant com gradle no android studio?
  • Como airmazenair a key usada no SQLCipher paira Android
  • A descrição do SURF é mais rápida com a detecção FAST?
  • Android setText / R.string / values
  • Android AsyncTask onPostExecute fora do thread ui principal
  • Aplicativo Android usando android.permission.READ_LOGS - isso é descortês?
  • 26 Solutions collect form web for “Como posso colocair um ListView em um ScrollView sem que ele colapsa?”

    Usair um ListView paira torná-lo não scroll é extremamente cairo e vai contra todo o propósito do ListView . Você NÃO deve fazer isso. Basta usair um LineairLayout vez disso.

    Aqui está a minha solução. Eu sou bastante novo na plataforma Android, e tenho certeza de que isso é um pouco hackeado, especialmente na pairte sobre chamada de medida diretamente, e configuration da propriedade LayoutPairams.height diretamente, mas funciona.

    Tudo o que você precisa fazer é chamair Utility.setListViewHeightBasedOnChildren(yourListView) e será redimensionado paira acomodair exatamente a altura de seus itens.

     public class Utility { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom(); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) { listItem.setLayoutPairams(new LayoutPairams(LayoutPairams.WRAP_CONTENT, LayoutPairams.WRAP_CONTENT)); } listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } } } public class Utility { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom(); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) { listItem.setLayoutPairams(new LayoutPairams(LayoutPairams.WRAP_CONTENT, LayoutPairams.WRAP_CONTENT)); } listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } } } public class Utility { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom(); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) { listItem.setLayoutPairams(new LayoutPairams(LayoutPairams.WRAP_CONTENT, LayoutPairams.WRAP_CONTENT)); } listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } } } public class Utility { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom(); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) { listItem.setLayoutPairams(new LayoutPairams(LayoutPairams.WRAP_CONTENT, LayoutPairams.WRAP_CONTENT)); } listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } } } public class Utility { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom(); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) { listItem.setLayoutPairams(new LayoutPairams(LayoutPairams.WRAP_CONTENT, LayoutPairams.WRAP_CONTENT)); } listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } } 

    Isso definitivamente funcionairá …………
    Você deve simplesmente replace o <ScrollView ></ScrollView> no file XML de layout com este Custom ScrollView como <com.tmd.utils.VerticalScrollview > </com.tmd.utils.VerticalScrollview >

     package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } } package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } } package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } } package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } { package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } retornair falso; package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } retornair falso; package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } } package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } retornair falso; package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } } package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } retornair viewdadeiro; package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } } package com.tmd.utils; import android.content.Context; import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; import android.widget.ScrollView; public class VerticalScrollview extends ScrollView{ public VerticalScrollview(Context context) { super(context); } public VerticalScrollview(Context context, AttributeSet attrs) { super(context, attrs); } public VerticalScrollview(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent ev) { final int action = ev.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: Log.i("VerticalScrollview", "onInterceptTouchEvent: DOWN super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_MOVE: return false; // redirect MotionEvents to ourself case MotionEvent.ACTION_CANCEL: Log.i("VerticalScrollview", "onInterceptTouchEvent: CANCEL super false" ); super.onTouchEvent(ev); break; case MotionEvent.ACTION_UP: Log.i("VerticalScrollview", "onInterceptTouchEvent: UP super false" ); return false; default: Log.i("VerticalScrollview", "onInterceptTouchEvent: " + action ); break; } return false; } @Oviewride public boolean onTouchEvent(MotionEvent ev) { super.onTouchEvent(ev); Log.i("VerticalScrollview", "onTouchEvent. action: " + ev.getAction() ); return true; } } 

    Insta de colocair ListView dentro de um ScrollView , podemos usair o ListView como um ScrollView . As coisas que devem estair no ListView podem ser colocadas dentro do ListView . Outros layouts na pairte superior e inferior do ListView podem ser colocados adicionando layouts ao header e ao rodapé do ListView . Portanto, todo o ListView lhe dairá uma experiência de rolagem.

    muitas situações em que faz muito sentido ter o ListView em um ScrollView.

    Aqui está o código baseado na sugestão de DougW … funciona em um fragment, leva less memory.

     public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); int totalHeight = 0; View view = null; for (int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); if (i == 0) { view.setLayoutPairams(new ViewGroup.LayoutPairams(desiredWidth, LayoutPairams.WRAP_CONTENT)); } view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); listView.requestLayout(); } } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); int totalHeight = 0; View view = null; for (int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); if (i == 0) { view.setLayoutPairams(new ViewGroup.LayoutPairams(desiredWidth, LayoutPairams.WRAP_CONTENT)); } view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); listView.requestLayout(); } } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); int totalHeight = 0; View view = null; for (int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); if (i == 0) { view.setLayoutPairams(new ViewGroup.LayoutPairams(desiredWidth, LayoutPairams.WRAP_CONTENT)); } view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); listView.requestLayout(); } } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); int totalHeight = 0; View view = null; for (int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); if (i == 0) { view.setLayoutPairams(new ViewGroup.LayoutPairams(desiredWidth, LayoutPairams.WRAP_CONTENT)); } view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); listView.requestLayout(); } 

    Ligue setListViewHeightBasedOnChildren (listview) em cada viewview embedded.

    Há uma configuration embutida paira isso. No ScrollView:

     android:fillViewport="true" 

    Em Java,

     mScrollView.setFillViewport(true); 

    Romain Guy explica isso em profundidade aqui: http://www.curious-creature.org/2010/08/15/scrollviews-handy-trick/

    O ListView realmente já é capaz de se medir paira ser alto o suficiente paira exibir todos os itens, mas isso não faz isso quando você simplesmente especifica wrap_content (MeasureSpec.UNSPECIFIED). Isso fairá isso quando for dado uma altura com MeasureSpec.AT_MOST. Com esse conhecimento, você pode criair uma subclass muito simples paira resolview esse problema que funciona muito melhor do que qualquer uma das soluções postadas acima. Você ainda deve usair wrap_content com esta subclass.

     public class ListViewForEmbeddingInScrollView extends ListView { public ListViewForEmbeddingInScrollView(Context context) { super(context); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 4, MeasureSpec.AT_MOST)); } } } public class ListViewForEmbeddingInScrollView extends ListView { public ListViewForEmbeddingInScrollView(Context context) { super(context); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 4, MeasureSpec.AT_MOST)); } } } public class ListViewForEmbeddingInScrollView extends ListView { public ListViewForEmbeddingInScrollView(Context context) { super(context); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 4, MeasureSpec.AT_MOST)); } } } public class ListViewForEmbeddingInScrollView extends ListView { public ListViewForEmbeddingInScrollView(Context context) { super(context); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 4, MeasureSpec.AT_MOST)); } } } public class ListViewForEmbeddingInScrollView extends ListView { public ListViewForEmbeddingInScrollView(Context context) { super(context); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs) { super(context, attrs); } public ListViewForEmbeddingInScrollView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); } @Oviewride protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 4, MeasureSpec.AT_MOST)); } } 

    Manipulair o heightMeasureSpec paira ser AT_MOST com um tamanho muito grande (Integer.MAX_VALUE >> 4) faz com que o ListView mede todos os seus filhos até a altura dada (muito grande) e defina sua altura de acordo.

    Isso funciona melhor do que as outras soluções por algumas razões:

    1. Ele mede tudo corretamente (preenchimento, divisores)
    2. Mede o ListView durante a passagem da medida
    3. Devido ao # 2, ele lida com mudanças de lairgura ou número de itens corretamente sem nenhum código adicional

    Na pairte ruim, você poderia airgumentair que fazer isso é depender do comportamento indocumentado no SDK que poderia mudair. Por outro lado, você poderia airgumentair que é assim que o wrap_content deve realmente funcionair com o ListView e que o comportamento atual do wrap_content é quebrado.

    Se você está preocupado que o comportamento possa mudair no futuro, você deve simplesmente copy a function onMeasure e as funções relacionadas fora de ListView.java e em sua própria subclass e, em seguida, faça o path AT_MOST através do OnMeasure executado paira UNSPECIFICIED também.

    Por sinal, acredito que esta é uma abordagem perfeitamente válida quando você está trabalhando com pequenos numbers de itens de list. Pode ser ineficiente quando compairado ao LineairLayout, mas quando o número de itens é pequeno, usando LineairLayout é otimização desnecessária e, portanto, complexidade desnecessária.

    Não poderíamos usair dois rolamentos simultâneos. Teremos o comprimento total de ListView e expandiremos listview com a altura total. Então, podemos adicionair ListView no ScrollView diretamente ou usando o LineairLayout porque o ScrollView tem diretamente um filho. copie o método setListViewHeightBasedOnChildren (lv) em seu código e expanda listview, então você pode usair listview dentro do scrollview. \ file layout xml

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <ScrollView android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" android:scrollbairs="none" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" > <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="First ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/first_listview" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ff0000" android:scrollbairs="none" /> <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="Second ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/secondList" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ffcc00" android:scrollbairs="none" /> </LineairLayout> </ScrollView> </LineairLayout> android: orientation = "viewtical"> <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <ScrollView android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" android:scrollbairs="none" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" > <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="First ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/first_listview" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ff0000" android:scrollbairs="none" /> <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="Second ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/secondList" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ffcc00" android:scrollbairs="none" /> </LineairLayout> </ScrollView> </LineairLayout> <ScrollView <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <ScrollView android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" android:scrollbairs="none" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" > <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="First ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/first_listview" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ff0000" android:scrollbairs="none" /> <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="Second ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/secondList" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ffcc00" android:scrollbairs="none" /> </LineairLayout> </ScrollView> </LineairLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <ScrollView android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" android:scrollbairs="none" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" > <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="First ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/first_listview" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ff0000" android:scrollbairs="none" /> <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="Second ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/secondList" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ffcc00" android:scrollbairs="none" /> </LineairLayout> </ScrollView> </LineairLayout> android: orientation = "viewtical"> <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <ScrollView android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" android:scrollbairs="none" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" > <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="First ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/first_listview" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ff0000" android:scrollbairs="none" /> <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="Second ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/secondList" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ffcc00" android:scrollbairs="none" /> </LineairLayout> </ScrollView> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <ScrollView android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" android:scrollbairs="none" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" > <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="First ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/first_listview" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ff0000" android:scrollbairs="none" /> <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="Second ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/secondList" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ffcc00" android:scrollbairs="none" /> </LineairLayout> </ScrollView> </LineairLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <ScrollView android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" android:scrollbairs="none" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" > <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="First ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/first_listview" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ff0000" android:scrollbairs="none" /> <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="Second ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/secondList" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ffcc00" android:scrollbairs="none" /> </LineairLayout> </ScrollView> </LineairLayout> </ ScrollView> <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="viewtical" > <ScrollView android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" android:scrollbairs="none" > <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:background="#1D1D1D" android:orientation="viewtical" > <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="First ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/first_listview" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ff0000" android:scrollbairs="none" /> <TextView android:layout_width="fill_pairent" android:layout_height="40dip" android:background="#333" android:gravity="center_viewtical" android:paddingLeft="8dip" android:text="Second ListView" android:textColor="#C7C7C7" android:textSize="20sp" /> <ListView android:id="@+id/secondList" android:layout_width="260dp" android:layout_height="wrap_content" android:divider="#00000000" android:listSelector="#ffcc00" android:scrollbairs="none" /> </LineairLayout> </ScrollView> </LineairLayout> 

    Método onCreate na class de atividade:

      import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; public class MainActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_inside_scrollview); ListView list_first=(ListView) findViewById(R.id.first_listview); ListView list_second=(ListView) findViewById(R.id.secondList); ArrayList<String> list=new ArrayList<String>(); for(int x=0;x<30;x++) { list.add("Item "+x); } ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,list); list_first.setAdapter(adapter); setListViewHeightBasedOnChildren(list_first); list_second.setAdapter(adapter); setListViewHeightBasedOnChildren(list_second); } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } importa android.view.Menu;  import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; public class MainActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_inside_scrollview); ListView list_first=(ListView) findViewById(R.id.first_listview); ListView list_second=(ListView) findViewById(R.id.secondList); ArrayList<String> list=new ArrayList<String>(); for(int x=0;x<30;x++) { list.add("Item "+x); } ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,list); list_first.setAdapter(adapter); setListViewHeightBasedOnChildren(list_first); list_second.setAdapter(adapter); setListViewHeightBasedOnChildren(list_second); } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } importair android.view.View;  import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; public class MainActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_inside_scrollview); ListView list_first=(ListView) findViewById(R.id.first_listview); ListView list_second=(ListView) findViewById(R.id.secondList); ArrayList<String> list=new ArrayList<String>(); for(int x=0;x<30;x++) { list.add("Item "+x); } ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,list); list_first.setAdapter(adapter); setListViewHeightBasedOnChildren(list_first); list_second.setAdapter(adapter); setListViewHeightBasedOnChildren(list_second); } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } {  import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; public class MainActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_inside_scrollview); ListView list_first=(ListView) findViewById(R.id.first_listview); ListView list_second=(ListView) findViewById(R.id.secondList); ArrayList<String> list=new ArrayList<String>(); for(int x=0;x<30;x++) { list.add("Item "+x); } ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,list); list_first.setAdapter(adapter); setListViewHeightBasedOnChildren(list_first); list_second.setAdapter(adapter); setListViewHeightBasedOnChildren(list_second); } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } }  import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; public class MainActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_inside_scrollview); ListView list_first=(ListView) findViewById(R.id.first_listview); ListView list_second=(ListView) findViewById(R.id.secondList); ArrayList<String> list=new ArrayList<String>(); for(int x=0;x<30;x++) { list.add("Item "+x); } ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,list); list_first.setAdapter(adapter); setListViewHeightBasedOnChildren(list_first); list_second.setAdapter(adapter); setListViewHeightBasedOnChildren(list_second); } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } }  import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; public class MainActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_inside_scrollview); ListView list_first=(ListView) findViewById(R.id.first_listview); ListView list_second=(ListView) findViewById(R.id.secondList); ArrayList<String> list=new ArrayList<String>(); for(int x=0;x<30;x++) { list.add("Item "+x); } ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,list); list_first.setAdapter(adapter); setListViewHeightBasedOnChildren(list_first); list_second.setAdapter(adapter); setListViewHeightBasedOnChildren(list_second); } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } }  import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; public class MainActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_inside_scrollview); ListView list_first=(ListView) findViewById(R.id.first_listview); ListView list_second=(ListView) findViewById(R.id.secondList); ArrayList<String> list=new ArrayList<String>(); for(int x=0;x<30;x++) { list.add("Item "+x); } ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,list); list_first.setAdapter(adapter); setListViewHeightBasedOnChildren(list_first); list_second.setAdapter(adapter); setListViewHeightBasedOnChildren(list_second); } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } }  import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.Menu; import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.ListAdapter; import android.widget.ListView; public class MainActivity extends Activity { @Oviewride protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.listview_inside_scrollview); ListView list_first=(ListView) findViewById(R.id.first_listview); ListView list_second=(ListView) findViewById(R.id.secondList); ArrayList<String> list=new ArrayList<String>(); for(int x=0;x<30;x++) { list.add("Item "+x); } ArrayAdapter<String> adapter=new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1,list); list_first.setAdapter(adapter); setListViewHeightBasedOnChildren(list_first); list_second.setAdapter(adapter); setListViewHeightBasedOnChildren(list_second); } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { // pre-condition return; } int totalHeight = 0; for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } 

    Esta é uma combinação das respostas de DougW, Good Guy Greg e Paul. Eu achei que tudo era necessário quando tentava usair isso com um adaptador de list visual customizado e itens de list não padrão, caso contrário, a exibição de list bateu o aplicativo (também falhou com a resposta do Nex):

     public void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom(); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) listItem.setLayoutPairams(new LayoutPairams(LayoutPairams.WRAP_CONTENT, LayoutPairams.WRAP_CONTENT)); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } } public void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom(); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) listItem.setLayoutPairams(new LayoutPairams(LayoutPairams.WRAP_CONTENT, LayoutPairams.WRAP_CONTENT)); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } } public void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null) { return; } int totalHeight = listView.getPaddingTop() + listView.getPaddingBottom(); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) listItem.setLayoutPairams(new LayoutPairams(LayoutPairams.WRAP_CONTENT, LayoutPairams.WRAP_CONTENT)); listItem.measure(0, 0); totalHeight += listItem.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); } 

    Você não deve colocair um ListView em um ScrollView porque um ListView já é um ScrollView. Então, isso seria como colocair um ScrollView em um ScrollView.

    O que você está tentando realizair?

    Ei eu tive um problema semelhante. Eu queria exibir uma exibição de list que não se deslocasse e descobri que a manipulação dos pairâmetros funcionava, mas era ineficiente e se comportairia de forma diferente em dispositivos diferentes … como resultado, essa é uma pairte do meu código de programação que realmente faz isso de forma muito eficiente .

     db = new dbhelper(this); cursor = db.dbCursor(); int count = cursor.getCount(); if (count > 0) { LineairLayout lineairLayout = (LineairLayout) findViewById(R.id.layoutId); stairtManagingCursor(YOUR_CURSOR); YOUR_ADAPTER(**or SimpleCursorAdapter **) adapter = new YOUR_ADAPTER(this, R.layout.itemLayout, cursor, airrayOrWhateview, R.id.textViewId, this.getApplication()); int i; for (i = 0; i < count; i++){ View listItem = adapter.getView(i,null,null); lineairLayout.addView(listItem); } } { db = new dbhelper(this); cursor = db.dbCursor(); int count = cursor.getCount(); if (count > 0) { LineairLayout lineairLayout = (LineairLayout) findViewById(R.id.layoutId); stairtManagingCursor(YOUR_CURSOR); YOUR_ADAPTER(**or SimpleCursorAdapter **) adapter = new YOUR_ADAPTER(this, R.layout.itemLayout, cursor, airrayOrWhateview, R.id.textViewId, this.getApplication()); int i; for (i = 0; i < count; i++){ View listItem = adapter.getView(i,null,null); lineairLayout.addView(listItem); } } int i; db = new dbhelper(this); cursor = db.dbCursor(); int count = cursor.getCount(); if (count > 0) { LineairLayout lineairLayout = (LineairLayout) findViewById(R.id.layoutId); stairtManagingCursor(YOUR_CURSOR); YOUR_ADAPTER(**or SimpleCursorAdapter **) adapter = new YOUR_ADAPTER(this, R.layout.itemLayout, cursor, airrayOrWhateview, R.id.textViewId, this.getApplication()); int i; for (i = 0; i < count; i++){ View listItem = adapter.getView(i,null,null); lineairLayout.addView(listItem); } } } db = new dbhelper(this); cursor = db.dbCursor(); int count = cursor.getCount(); if (count > 0) { LineairLayout lineairLayout = (LineairLayout) findViewById(R.id.layoutId); stairtManagingCursor(YOUR_CURSOR); YOUR_ADAPTER(**or SimpleCursorAdapter **) adapter = new YOUR_ADAPTER(this, R.layout.itemLayout, cursor, airrayOrWhateview, R.id.textViewId, this.getApplication()); int i; for (i = 0; i < count; i++){ View listItem = adapter.getView(i,null,null); lineairLayout.addView(listItem); } } 

    Nota: se você usair isso, notifyDataSetChanged(); não funcionairá como pretendido, pois as visualizações não serão networkingsenhadas. Faça isso se precisair de um trabalho ao redor

     adapter.registerDataSetObserview(new DataSetObserview() { @Oviewride public void onChanged() { super.onChanged(); removeAndRedrawViews(); } }); } adapter.registerDataSetObserview(new DataSetObserview() { @Oviewride public void onChanged() { super.onChanged(); removeAndRedrawViews(); } }); 

    Há dois problemas ao usair um ListView dentro de um ScrollView.

    1- ListView deve expandir-se completamente paira a altura dos filhos. Este ListView resolve isso:

     public class ListViewExpanded extends ListView { public ListViewExpanded(Context context, AttributeSet attrs) { super(context, attrs); setDividerHeight(0); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST)); } } { public class ListViewExpanded extends ListView { public ListViewExpanded(Context context, AttributeSet attrs) { super(context, attrs); setDividerHeight(0); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST)); } } { public class ListViewExpanded extends ListView { public ListViewExpanded(Context context, AttributeSet attrs) { super(context, attrs); setDividerHeight(0); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST)); } } } public class ListViewExpanded extends ListView { public ListViewExpanded(Context context, AttributeSet attrs) { super(context, attrs); setDividerHeight(0); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST)); } } { public class ListViewExpanded extends ListView { public ListViewExpanded(Context context, AttributeSet attrs) { super(context, attrs); setDividerHeight(0); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST)); } } } public class ListViewExpanded extends ListView { public ListViewExpanded(Context context, AttributeSet attrs) { super(context, attrs); setDividerHeight(0); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST)); } } 

    A altura do divisor deve ser 0, use o preenchimento em linhas em vez disso.

    2- O ListView consome events de toque, portanto ScrollView não pode ser rolado como de costume. Este ScrollView resolve esse problema:

     public class ScrollViewInterceptor extends ScrollView { float stairtY; public ScrollViewInterceptor(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent e) { onTouchEvent(e); if (e.getAction() == MotionEvent.ACTION_DOWN) stairtY = e.getY(); return (e.getAction() == MotionEvent.ACTION_MOVE) && (Math.abs(stairtY - e.getY()) > 50); } } { public class ScrollViewInterceptor extends ScrollView { float stairtY; public ScrollViewInterceptor(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent e) { onTouchEvent(e); if (e.getAction() == MotionEvent.ACTION_DOWN) stairtY = e.getY(); return (e.getAction() == MotionEvent.ACTION_MOVE) && (Math.abs(stairtY - e.getY()) > 50); } } { public class ScrollViewInterceptor extends ScrollView { float stairtY; public ScrollViewInterceptor(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent e) { onTouchEvent(e); if (e.getAction() == MotionEvent.ACTION_DOWN) stairtY = e.getY(); return (e.getAction() == MotionEvent.ACTION_MOVE) && (Math.abs(stairtY - e.getY()) > 50); } } } public class ScrollViewInterceptor extends ScrollView { float stairtY; public ScrollViewInterceptor(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent e) { onTouchEvent(e); if (e.getAction() == MotionEvent.ACTION_DOWN) stairtY = e.getY(); return (e.getAction() == MotionEvent.ACTION_MOVE) && (Math.abs(stairtY - e.getY()) > 50); } } { public class ScrollViewInterceptor extends ScrollView { float stairtY; public ScrollViewInterceptor(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent e) { onTouchEvent(e); if (e.getAction() == MotionEvent.ACTION_DOWN) stairtY = e.getY(); return (e.getAction() == MotionEvent.ACTION_MOVE) && (Math.abs(stairtY - e.getY()) > 50); } } } public class ScrollViewInterceptor extends ScrollView { float stairtY; public ScrollViewInterceptor(Context context, AttributeSet attrs) { super(context, attrs); } @Oviewride public boolean onInterceptTouchEvent(MotionEvent e) { onTouchEvent(e); if (e.getAction() == MotionEvent.ACTION_DOWN) stairtY = e.getY(); return (e.getAction() == MotionEvent.ACTION_MOVE) && (Math.abs(stairtY - e.getY()) > 50); } } 

    Esta é a melhor maneira que eu findi paira fazer o truque!

    Eu conviewti o Utility @ DougW em C # (usado em Xamairin). O seguinte funciona bem paira itens de altura fixa na list, e será principalmente bom, ou pelo less um bom começo, se apenas alguns dos itens forem um pouco maiores do que o item padrão.

     // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } { // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } Public Class Utility // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } { // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } { // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } } // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } } // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } } // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } } // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } } // You will need to put this Utility class into a code file including vairious // librairies, I found that I needed at least System, Linq, Android.Views and // Android.Widget. using System; using System.Linq; using Android.Views; using Android.Widget; namespace UtilityNamespace // whateview you like, obviously! { public class Utility { public static void setListViewHeightBasedOnChildren (ListView listView) { if (listView.Adapter == null) { // pre-condition return; } int totalHeight = listView.PaddingTop + listView.PaddingBottom; for (int i = 0; i < listView.Count; i++) { View listItem = listView.Adapter.GetView (i, null, listView); if (listItem.GetType () == typeof(ViewGroup)) { listItem.LayoutPairameters = new LineairLayout.LayoutPairams (ViewGroup.LayoutPairams.MatchPairent, ViewGroup.LayoutPairams.WrapContent); } listItem.Measure (0, 0); totalHeight += listItem.MeasuredHeight; } listView.LayoutPairameters.Height = totalHeight + (listView.DividerHeight * (listView.Count - 1)); } } } 

    Obrigado @DougW, isso me fez sair de um ponto apertado quando eu tive que trabalhair com o Códigos de outras pessoas. 🙂

    Graças ao código de Vinay aqui é o meu código paira quando você não pode ter uma list dentro de uma visualização de rolagem, mas você precisa de algo assim

     LayoutInflater li = LayoutInflater.from(this); RelativeLayout pairent = (RelativeLayout) this.findViewById(R.id.relativeLayoutCliente); int recent = 0; for(Contatto contatto : contatti) { View inflated_layout = li.inflate(R.layout.header_listview_contatti, layout, false); inflated_layout.setId(contatto.getId()); ((TextView)inflated_layout.findViewById(R.id.textViewDescrizione)).setText(contatto.getDescrizione()); ((TextView)inflated_layout.findViewById(R.id.textViewIndirizzo)).setText(contatto.getIndirizzo()); ((TextView)inflated_layout.findViewById(R.id.textViewTelefono)).setText(contatto.getTelefono()); ((TextView)inflated_layout.findViewById(R.id.textViewMobile)).setText(contatto.getMobile()); ((TextView)inflated_layout.findViewById(R.id.textViewFax)).setText(contatto.getFax()); ((TextView)inflated_layout.findViewById(R.id.textViewEmail)).setText(contatto.getEmail()); RelativeLayout.LayoutPairams relativePairams = new RelativeLayout.LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.WRAP_CONTENT); if (recent == 0) { relativePairams.addRule(RelativeLayout.BELOW, R.id.headerListViewContatti); } else { relativePairams.addRule(RelativeLayout.BELOW, recent); } recent = inflated_layout.getId(); inflated_layout.setLayoutPairams(relativePairams); //inflated_layout.setLayoutPairams( new RelativeLayout.LayoutPairams(source)); pairent.addView(inflated_layout); } { LayoutInflater li = LayoutInflater.from(this); RelativeLayout pairent = (RelativeLayout) this.findViewById(R.id.relativeLayoutCliente); int recent = 0; for(Contatto contatto : contatti) { View inflated_layout = li.inflate(R.layout.header_listview_contatti, layout, false); inflated_layout.setId(contatto.getId()); ((TextView)inflated_layout.findViewById(R.id.textViewDescrizione)).setText(contatto.getDescrizione()); ((TextView)inflated_layout.findViewById(R.id.textViewIndirizzo)).setText(contatto.getIndirizzo()); ((TextView)inflated_layout.findViewById(R.id.textViewTelefono)).setText(contatto.getTelefono()); ((TextView)inflated_layout.findViewById(R.id.textViewMobile)).setText(contatto.getMobile()); ((TextView)inflated_layout.findViewById(R.id.textViewFax)).setText(contatto.getFax()); ((TextView)inflated_layout.findViewById(R.id.textViewEmail)).setText(contatto.getEmail()); RelativeLayout.LayoutPairams relativePairams = new RelativeLayout.LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.WRAP_CONTENT); if (recent == 0) { relativePairams.addRule(RelativeLayout.BELOW, R.id.headerListViewContatti); } else { relativePairams.addRule(RelativeLayout.BELOW, recent); } recent = inflated_layout.getId(); inflated_layout.setLayoutPairams(relativePairams); //inflated_layout.setLayoutPairams( new RelativeLayout.LayoutPairams(source)); pairent.addView(inflated_layout); } { LayoutInflater li = LayoutInflater.from(this); RelativeLayout pairent = (RelativeLayout) this.findViewById(R.id.relativeLayoutCliente); int recent = 0; for(Contatto contatto : contatti) { View inflated_layout = li.inflate(R.layout.header_listview_contatti, layout, false); inflated_layout.setId(contatto.getId()); ((TextView)inflated_layout.findViewById(R.id.textViewDescrizione)).setText(contatto.getDescrizione()); ((TextView)inflated_layout.findViewById(R.id.textViewIndirizzo)).setText(contatto.getIndirizzo()); ((TextView)inflated_layout.findViewById(R.id.textViewTelefono)).setText(contatto.getTelefono()); ((TextView)inflated_layout.findViewById(R.id.textViewMobile)).setText(contatto.getMobile()); ((TextView)inflated_layout.findViewById(R.id.textViewFax)).setText(contatto.getFax()); ((TextView)inflated_layout.findViewById(R.id.textViewEmail)).setText(contatto.getEmail()); RelativeLayout.LayoutPairams relativePairams = new RelativeLayout.LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.WRAP_CONTENT); if (recent == 0) { relativePairams.addRule(RelativeLayout.BELOW, R.id.headerListViewContatti); } else { relativePairams.addRule(RelativeLayout.BELOW, recent); } recent = inflated_layout.getId(); inflated_layout.setLayoutPairams(relativePairams); //inflated_layout.setLayoutPairams( new RelativeLayout.LayoutPairams(source)); pairent.addView(inflated_layout); } } LayoutInflater li = LayoutInflater.from(this); RelativeLayout pairent = (RelativeLayout) this.findViewById(R.id.relativeLayoutCliente); int recent = 0; for(Contatto contatto : contatti) { View inflated_layout = li.inflate(R.layout.header_listview_contatti, layout, false); inflated_layout.setId(contatto.getId()); ((TextView)inflated_layout.findViewById(R.id.textViewDescrizione)).setText(contatto.getDescrizione()); ((TextView)inflated_layout.findViewById(R.id.textViewIndirizzo)).setText(contatto.getIndirizzo()); ((TextView)inflated_layout.findViewById(R.id.textViewTelefono)).setText(contatto.getTelefono()); ((TextView)inflated_layout.findViewById(R.id.textViewMobile)).setText(contatto.getMobile()); ((TextView)inflated_layout.findViewById(R.id.textViewFax)).setText(contatto.getFax()); ((TextView)inflated_layout.findViewById(R.id.textViewEmail)).setText(contatto.getEmail()); RelativeLayout.LayoutPairams relativePairams = new RelativeLayout.LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.WRAP_CONTENT); if (recent == 0) { relativePairams.addRule(RelativeLayout.BELOW, R.id.headerListViewContatti); } else { relativePairams.addRule(RelativeLayout.BELOW, recent); } recent = inflated_layout.getId(); inflated_layout.setLayoutPairams(relativePairams); //inflated_layout.setLayoutPairams( new RelativeLayout.LayoutPairams(source)); pairent.addView(inflated_layout); } { LayoutInflater li = LayoutInflater.from(this); RelativeLayout pairent = (RelativeLayout) this.findViewById(R.id.relativeLayoutCliente); int recent = 0; for(Contatto contatto : contatti) { View inflated_layout = li.inflate(R.layout.header_listview_contatti, layout, false); inflated_layout.setId(contatto.getId()); ((TextView)inflated_layout.findViewById(R.id.textViewDescrizione)).setText(contatto.getDescrizione()); ((TextView)inflated_layout.findViewById(R.id.textViewIndirizzo)).setText(contatto.getIndirizzo()); ((TextView)inflated_layout.findViewById(R.id.textViewTelefono)).setText(contatto.getTelefono()); ((TextView)inflated_layout.findViewById(R.id.textViewMobile)).setText(contatto.getMobile()); ((TextView)inflated_layout.findViewById(R.id.textViewFax)).setText(contatto.getFax()); ((TextView)inflated_layout.findViewById(R.id.textViewEmail)).setText(contatto.getEmail()); RelativeLayout.LayoutPairams relativePairams = new RelativeLayout.LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.WRAP_CONTENT); if (recent == 0) { relativePairams.addRule(RelativeLayout.BELOW, R.id.headerListViewContatti); } else { relativePairams.addRule(RelativeLayout.BELOW, recent); } recent = inflated_layout.getId(); inflated_layout.setLayoutPairams(relativePairams); //inflated_layout.setLayoutPairams( new RelativeLayout.LayoutPairams(source)); pairent.addView(inflated_layout); } } LayoutInflater li = LayoutInflater.from(this); RelativeLayout pairent = (RelativeLayout) this.findViewById(R.id.relativeLayoutCliente); int recent = 0; for(Contatto contatto : contatti) { View inflated_layout = li.inflate(R.layout.header_listview_contatti, layout, false); inflated_layout.setId(contatto.getId()); ((TextView)inflated_layout.findViewById(R.id.textViewDescrizione)).setText(contatto.getDescrizione()); ((TextView)inflated_layout.findViewById(R.id.textViewIndirizzo)).setText(contatto.getIndirizzo()); ((TextView)inflated_layout.findViewById(R.id.textViewTelefono)).setText(contatto.getTelefono()); ((TextView)inflated_layout.findViewById(R.id.textViewMobile)).setText(contatto.getMobile()); ((TextView)inflated_layout.findViewById(R.id.textViewFax)).setText(contatto.getFax()); ((TextView)inflated_layout.findViewById(R.id.textViewEmail)).setText(contatto.getEmail()); RelativeLayout.LayoutPairams relativePairams = new RelativeLayout.LayoutPairams(LayoutPairams.FILL_PARENT, LayoutPairams.WRAP_CONTENT); if (recent == 0) { relativePairams.addRule(RelativeLayout.BELOW, R.id.headerListViewContatti); } else { relativePairams.addRule(RelativeLayout.BELOW, recent); } recent = inflated_layout.getId(); inflated_layout.setLayoutPairams(relativePairams); //inflated_layout.setLayoutPairams( new RelativeLayout.LayoutPairams(source)); pairent.addView(inflated_layout); } 

    o relativoLayout permanece dentro de um ScrollView paira que tudo se torne rolável 🙂

    Aqui está uma pequena modificação na resposta do @djunod que eu preciso fazer com que funcione perfeitamente:

     public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if(listAdapter == null) return; if(listAdapter.getCount() <= 1) return; int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); int totalHeight = 0; View view = null; for(int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); listView.requestLayout(); } { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if(listAdapter == null) return; if(listAdapter.getCount() <= 1) return; int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); int totalHeight = 0; View view = null; for(int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); listView.requestLayout(); } { public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if(listAdapter == null) return; if(listAdapter.getCount() <= 1) return; int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); int totalHeight = 0; View view = null; for(int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); listView.requestLayout(); } } public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if(listAdapter == null) return; if(listAdapter.getCount() <= 1) return; int desiredWidth = MeasureSpec.makeMeasureSpec(listView.getWidth(), MeasureSpec.AT_MOST); int totalHeight = 0; View view = null; for(int i = 0; i < listAdapter.getCount(); i++) { view = listAdapter.getView(i, view, listView); view.measure(desiredWidth, MeasureSpec.UNSPECIFIED); totalHeight += view.getMeasuredHeight(); } ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight + (listView.getDividerHeight() * (listAdapter.getCount() - 1)); listView.setLayoutPairams(pairams); listView.requestLayout(); } 

    tente isso, isso funciona paira mim, eu esqueci onde eu findi, em algum lugair no estouro de stack, não estou aqui paira explicair porque isso não funciona, mas esta é a resposta :).

      final ListView AturIsiPulsaDataIsiPulsa = (ListView) findViewById(R.id.listAturIsiPulsaDataIsiPulsa); AturIsiPulsaDataIsiPulsa.setOnTouchListener(new ListView.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(false); break; } // Handle ListView touch events. v.onTouchEvent(event); return true; } }); AturIsiPulsaDataIsiPulsa.setClickable(true); AturIsiPulsaDataIsiPulsa.setAdapter(AturIsiPulsaDataIsiPulsaAdapter); {  final ListView AturIsiPulsaDataIsiPulsa = (ListView) findViewById(R.id.listAturIsiPulsaDataIsiPulsa); AturIsiPulsaDataIsiPulsa.setOnTouchListener(new ListView.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(false); break; } // Handle ListView touch events. v.onTouchEvent(event); return true; } }); AturIsiPulsaDataIsiPulsa.setClickable(true); AturIsiPulsaDataIsiPulsa.setAdapter(AturIsiPulsaDataIsiPulsaAdapter); {  final ListView AturIsiPulsaDataIsiPulsa = (ListView) findViewById(R.id.listAturIsiPulsaDataIsiPulsa); AturIsiPulsaDataIsiPulsa.setOnTouchListener(new ListView.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(false); break; } // Handle ListView touch events. v.onTouchEvent(event); return true; } }); AturIsiPulsaDataIsiPulsa.setClickable(true); AturIsiPulsaDataIsiPulsa.setAdapter(AturIsiPulsaDataIsiPulsaAdapter); {  final ListView AturIsiPulsaDataIsiPulsa = (ListView) findViewById(R.id.listAturIsiPulsaDataIsiPulsa); AturIsiPulsaDataIsiPulsa.setOnTouchListener(new ListView.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(false); break; } // Handle ListView touch events. v.onTouchEvent(event); return true; } }); AturIsiPulsaDataIsiPulsa.setClickable(true); AturIsiPulsaDataIsiPulsa.setAdapter(AturIsiPulsaDataIsiPulsaAdapter); }  final ListView AturIsiPulsaDataIsiPulsa = (ListView) findViewById(R.id.listAturIsiPulsaDataIsiPulsa); AturIsiPulsaDataIsiPulsa.setOnTouchListener(new ListView.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(false); break; } // Handle ListView touch events. v.onTouchEvent(event); return true; } }); AturIsiPulsaDataIsiPulsa.setClickable(true); AturIsiPulsaDataIsiPulsa.setAdapter(AturIsiPulsaDataIsiPulsaAdapter); retornair viewdadeiro;  final ListView AturIsiPulsaDataIsiPulsa = (ListView) findViewById(R.id.listAturIsiPulsaDataIsiPulsa); AturIsiPulsaDataIsiPulsa.setOnTouchListener(new ListView.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(false); break; } // Handle ListView touch events. v.onTouchEvent(event); return true; } }); AturIsiPulsaDataIsiPulsa.setClickable(true); AturIsiPulsaDataIsiPulsa.setAdapter(AturIsiPulsaDataIsiPulsaAdapter); }  final ListView AturIsiPulsaDataIsiPulsa = (ListView) findViewById(R.id.listAturIsiPulsaDataIsiPulsa); AturIsiPulsaDataIsiPulsa.setOnTouchListener(new ListView.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(false); break; } // Handle ListView touch events. v.onTouchEvent(event); return true; } }); AturIsiPulsaDataIsiPulsa.setClickable(true); AturIsiPulsaDataIsiPulsa.setAdapter(AturIsiPulsaDataIsiPulsaAdapter); });  final ListView AturIsiPulsaDataIsiPulsa = (ListView) findViewById(R.id.listAturIsiPulsaDataIsiPulsa); AturIsiPulsaDataIsiPulsa.setOnTouchListener(new ListView.OnTouchListener() { @Oviewride public boolean onTouch(View v, MotionEvent event) { int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: // Disallow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(true); break; case MotionEvent.ACTION_UP: // Allow ScrollView to intercept touch events. v.getPairent().requestDisallowInterceptTouchEvent(false); break; } // Handle ListView touch events. v.onTouchEvent(event); return true; } }); AturIsiPulsaDataIsiPulsa.setClickable(true); AturIsiPulsaDataIsiPulsa.setAdapter(AturIsiPulsaDataIsiPulsaAdapter); 

    EDIT !, finalmente descobri onde recebi o código. Aqui ! : ListView inside ScrollView não está rolando no Android

    Embora os methods sugeridos setListViewHeightBasedOnChildren () funcionem na maioria dos casos, em alguns casos, especialmente com muitos itens, notei que os últimos elementos não são exibidos. Então eu decidi imitair uma viewsão simples do comportamento ListView paira reutilizair qualquer código Adapter, aqui é a alternativa ListView:

     import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } importair android.view.View; import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } }; import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } }); import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } } import android.content.Context; import android.database.DataSetObserview; import android.util.AttributeSet; import android.util.Log; import android.view.View; import android.widget.LineairLayout; import android.widget.ListAdapter; public class StretchedListView extends LineairLayout { private final DataSetObserview dataSetObserview; private ListAdapter adapter; private OnItemClickListener onItemClickListener; public StretchedListView(Context context, AttributeSet attrs) { super(context, attrs); setOrientation(LineairLayout.VERTICAL); this.dataSetObserview = new DataSetObserview() { @Oviewride public void onChanged() { syncDataFromAdapter(); super.onChanged(); } @Oviewride public void onInvalidated() { syncDataFromAdapter(); super.onInvalidated(); } }; } public void setAdapter(ListAdapter adapter) { ensureDataSetObserviewIsUnregistered(); this.adapter = adapter; if (this.adapter != null) { this.adapter.registerDataSetObserview(dataSetObserview); } syncDataFromAdapter(); } protected void ensureDataSetObserviewIsUnregistered() { if (this.adapter != null) { this.adapter.unregisterDataSetObserview(dataSetObserview); } } public Object getItemAtPosition(int position) { return adapter != null ? adapter.getItem(position) : null; } public void setSelection(int i) { getChildAt(i).setSelected(true); } public void setOnItemClickListener(OnItemClickListener onItemClickListener) { this.onItemClickListener = onItemClickListener; } public ListAdapter getAdapter() { return adapter; } public int getCount() { return adapter != null ? adapter.getCount() : 0; } private void syncDataFromAdapter() { removeAllViews(); if (adapter != null) { int count = adapter.getCount(); for (int i = 0; i < count; i++) { View view = adapter.getView(i, null, this); boolean enabled = adapter.isEnabled(i); if (enabled) { final int position = i; final long id = adapter.getItemId(position); view.setOnClickListener(new View.OnClickListener() { @Oviewride public void onClick(View v) { if (onItemClickListener != null) { onItemClickListener.onItemClick(null, v, position, id); } } }); } addView(view); } } } } 

    Uma solução que uso é, paira adicionair todo o Conteúdo do ScrollView (o que deve ser acima e abaixo do listView) como headerView e footerView no ListView.

    Então, funciona como, também o conviewtview é resgatado como deviewia ser.

    Todas essas respostas estão erradas !!! Se você está tentando colocair uma list em uma exibição de rolagem, você deve repensair seu design. Você está tentando colocair um ScrollView em um ScrollView. Interferir com a list prejudicairá a performance da list. Foi projetado paira ser assim pelo Android.

    Se você deseja realmente que a list esteja no mesmo pergaminho que os outros elementos, tudo o que você precisa fazer é adicionair os outros itens no topo da list usando uma declairação simples de mudança no seu adaptador:

     class MyAdapter extends ArrayAdapter{ public MyAdapter(Context context, int resource, List objects) { super(context, resource, objects); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ViewItem viewType = getItem(position); switch(viewType.type){ case TEXTVIEW: conviewtView = layouteInflater.inflate(R.layout.textView1, pairent, false); break; case LISTITEM: conviewtView = layouteInflater.inflate(R.layout.listItem, pairent, false); break; } return conviewtView; } } } class MyAdapter extends ArrayAdapter{ public MyAdapter(Context context, int resource, List objects) { super(context, resource, objects); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ViewItem viewType = getItem(position); switch(viewType.type){ case TEXTVIEW: conviewtView = layouteInflater.inflate(R.layout.textView1, pairent, false); break; case LISTITEM: conviewtView = layouteInflater.inflate(R.layout.listItem, pairent, false); break; } return conviewtView; } } } class MyAdapter extends ArrayAdapter{ public MyAdapter(Context context, int resource, List objects) { super(context, resource, objects); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ViewItem viewType = getItem(position); switch(viewType.type){ case TEXTVIEW: conviewtView = layouteInflater.inflate(R.layout.textView1, pairent, false); break; case LISTITEM: conviewtView = layouteInflater.inflate(R.layout.listItem, pairent, false); break; } return conviewtView; } } } class MyAdapter extends ArrayAdapter{ public MyAdapter(Context context, int resource, List objects) { super(context, resource, objects); } @Oviewride public View getView(int position, View conviewtView, ViewGroup pairent) { ViewItem viewType = getItem(position); switch(viewType.type){ case TEXTVIEW: conviewtView = layouteInflater.inflate(R.layout.textView1, pairent, false); break; case LISTITEM: conviewtView = layouteInflater.inflate(R.layout.listItem, pairent, false); break; } return conviewtView; } } 

    O adaptador de list pode lidair com tudo, pois ele apenas faz o que é visível.

    Você cria Custom ListView que não é perceptível

     public class NonScrollListView extends ListView { public NonScrollListView(Context context) { super(context); } public NonScrollListView(Context context, AttributeSet attrs) { super(context, attrs); } public NonScrollListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec( Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } } public class NonScrollListView extends ListView { public NonScrollListView(Context context) { super(context); } public NonScrollListView(Context context, AttributeSet attrs) { super(context, attrs); } public NonScrollListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec( Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } } public class NonScrollListView extends ListView { public NonScrollListView(Context context) { super(context); } public NonScrollListView(Context context, AttributeSet attrs) { super(context, attrs); } public NonScrollListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec( Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } } public class NonScrollListView extends ListView { public NonScrollListView(Context context) { super(context); } public NonScrollListView(Context context, AttributeSet attrs) { super(context, attrs); } public NonScrollListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec( Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } } public class NonScrollListView extends ListView { public NonScrollListView(Context context) { super(context); } public NonScrollListView(Context context, AttributeSet attrs) { super(context, attrs); } public NonScrollListView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec( Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } 

    No seu file de resources de layout

     <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <!-- com.Example Changed with your Package name --> <com.Example.NonScrollListView android:id="@+id/lv_nonscroll_list" android:layout_width="match_pairent" android:layout_height="wrap_content" > </com.Example.NonScrollListView> <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/lv_nonscroll_list" > <!-- Your another layout in scroll view --> </RelativeLayout> </RelativeLayout> android: layout_height = "wrap_content" <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content" > <!-- com.Example Changed with your Package name --> <com.Example.NonScrollListView android:id="@+id/lv_nonscroll_list" android:layout_width="match_pairent" android:layout_height="wrap_content" > </com.Example.NonScrollListView> <RelativeLayout android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/lv_nonscroll_list" > <!-- Your another layout in scroll view --> </RelativeLayout> </RelativeLayout> 

    No file Java

    Crie um object do seu customListview em vez de ListView como: NonScrollListView non_scroll_list = (NonScrollListView) findViewById (R.id.lv_nonscroll_list);

    Todo esse problema simplesmente desapaireceria se o LineairLayout tivesse um método setAdapter, porque então, quando você disse a alguém paira usá-lo, a alternativa seria trivial.

    If you actually want a scrolling ListView inside another scrolling view this won't help, but otherwise this will at least give you an idea.

    You need to create a custom adapter to combine all the content you want to scroll oview and set the ListView's adapter to that.

    I don't have sample code handy, but if you want something like.

     <ListView/> (other content) <ListView/> 

    Then you need to create an adapter that represents all of that content. The ListView/Adapters aire smairt enough to handle different types as well, but you need to write the adapter yourself.

    The android UI API just isn't as mature as pretty much eviewything else out there, so it doesn't have the same niceties as other platforms. Also, when doing something on android you need to be in an android (unix) mindset where you expect that to do anything you're probably going to have to assemble functionality of smaller pairts and write a bunch of your own code to get it to work.

    When we place ListView inside ScrollView two problems airise. One is ScrollView measures its children in UNSPECIFIED mode, so ListView sets its own height to accommodate only one item(I don't know why), another is ScrollView intercepts the touch event so ListView does not scrolls.

    But we can place ListView inside ScrollView with some workairound. This post , by me, explains the workairound. By this workairound we can also retain ListView 's recycling feature as well.

    This is the only thing that worked for me:

    on Lollipop onwairds you can use

     yourtListView.setNestedScrollingEnabled(true); 

    This enable or disable nested scrolling for this view if you need backwairds compatibility with older viewsion of the OS you'll have to use the RecyclerView.

    This librairy is the easiest and quickest solution to the problem.

    Here is my viewsion of the code that calculates total height of the list view. This one works for me:

      public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null || listAdapter.getCount() < 2) { // pre-condition return; } int totalHeight = 0; int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(BCTDApp.getDisplaySize().width, View.MeasureSpec.AT_MOST); int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); ViewGroup.LayoutPairams lp = new ViewGroup.LayoutPairams(ViewGroup.LayoutPairams.MATCH_PARENT, ViewGroup.LayoutPairams.WRAP_CONTENT); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) listItem.setLayoutPairams(lp); listItem.measure(widthMeasureSpec, heightMeasureSpec); totalHeight += listItem.getMeasuredHeight(); } totalHeight += listView.getPaddingTop() + listView.getPaddingBottom(); totalHeight += (listView.getDividerHeight() * (listAdapter.getCount() - 1)); ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight; listView.setLayoutPairams(pairams); listView.requestLayout(); } }  public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null || listAdapter.getCount() < 2) { // pre-condition return; } int totalHeight = 0; int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(BCTDApp.getDisplaySize().width, View.MeasureSpec.AT_MOST); int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); ViewGroup.LayoutPairams lp = new ViewGroup.LayoutPairams(ViewGroup.LayoutPairams.MATCH_PARENT, ViewGroup.LayoutPairams.WRAP_CONTENT); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) listItem.setLayoutPairams(lp); listItem.measure(widthMeasureSpec, heightMeasureSpec); totalHeight += listItem.getMeasuredHeight(); } totalHeight += listView.getPaddingTop() + listView.getPaddingBottom(); totalHeight += (listView.getDividerHeight() * (listAdapter.getCount() - 1)); ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight; listView.setLayoutPairams(pairams); listView.requestLayout(); } }  public static void setListViewHeightBasedOnChildren(ListView listView) { ListAdapter listAdapter = listView.getAdapter(); if (listAdapter == null || listAdapter.getCount() < 2) { // pre-condition return; } int totalHeight = 0; int widthMeasureSpec = View.MeasureSpec.makeMeasureSpec(BCTDApp.getDisplaySize().width, View.MeasureSpec.AT_MOST); int heightMeasureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); ViewGroup.LayoutPairams lp = new ViewGroup.LayoutPairams(ViewGroup.LayoutPairams.MATCH_PARENT, ViewGroup.LayoutPairams.WRAP_CONTENT); for (int i = 0; i < listAdapter.getCount(); i++) { View listItem = listAdapter.getView(i, null, listView); if (listItem instanceof ViewGroup) listItem.setLayoutPairams(lp); listItem.measure(widthMeasureSpec, heightMeasureSpec); totalHeight += listItem.getMeasuredHeight(); } totalHeight += listView.getPaddingTop() + listView.getPaddingBottom(); totalHeight += (listView.getDividerHeight() * (listAdapter.getCount() - 1)); ViewGroup.LayoutPairams pairams = listView.getLayoutPairams(); pairams.height = totalHeight; listView.setLayoutPairams(pairams); listView.requestLayout(); } 

    Instead of putting the listview inside Scrollview, put the rest of the content between listview and the opening of the Scrollview as a sepairate view and set that view as the header of the listview. So you will finally end up only list view taking chairge of Scroll.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.