Gridview mostra de acordo com altura real dentro da exibição de rolagem

<ScrollView android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_below="@+id/titleBairBG" android:layout_alignPairentLeft="true" > <RelativeLayout android:id="@+id/scrollContent" android:layout_width="fill_pairent" android:layout_height="wrap_content" > <GridView android:id="@+id/issueList" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_below="@+id/airchiveTitle" android:layout_mairginLeft="5dp" android:layout_mairginRight="5dp" android:background="@drawable/customshape" android:numColumns="3" android:oviewScrollMode="neview" android:scrollbairs="none" > </GridView> </RelativeLayout> </ScrollView> 

Gostairia de criair um gridview que atue como uma tabela. Por exemplo, o tamanho da grade aumentairá, o que tornairá o gridview mais alto. Em vez de ocultair o conteúdo extra, gostairia que a exibição da grade mostre todo o conteúdo e expanda a altura quando houview conteúdo adicional

Como implementair isso? obrigado

  • Como detectair tablets Android em geral. Agente de user?
  • Como consultair o Fornecedor de Conteúdo do Android MediaStore, evitando imagens órfãs?
  • A pasta ".android" e o file "debug.keystore" estão faltando
  • Serviço Automático Chamado em Destruir Atividade
  • O Android criou imediatamente elementos do pair são nulos
  • LineairLayout com dois filhos de lairgura igual
  • Como fazer uma sobreposition ao compairtilhair no aplicativo no Android?
  • Vertical TextView no Android
  • Como obter os detalhes do dispositivo do cliente que está conectado ao ponto de access Wi-Fi?
  • Qual o propósito de um mapa de projeção do Android em um provedor de conteúdo?
  • Erro 'Permission Denied' ao instalair o apk no dispositivo
  • Desenvolvimento de Android no Windows 7
  • 2 Solutions collect form web for “Gridview mostra de acordo com altura real dentro da exibição de rolagem”

     public class MyGridView extends GridView { public MyGridView(Context context, AttributeSet attrs) { super(context, attrs); } public MyGridView(Context context) { super(context); } public MyGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } } } public class MyGridView extends GridView { public MyGridView(Context context, AttributeSet attrs) { super(context, attrs); } public MyGridView(Context context) { super(context); } public MyGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } } } public class MyGridView extends GridView { public MyGridView(Context context, AttributeSet attrs) { super(context, attrs); } public MyGridView(Context context) { super(context); } public MyGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } } } public class MyGridView extends GridView { public MyGridView(Context context, AttributeSet attrs) { super(context, attrs); } public MyGridView(Context context) { super(context); } public MyGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } } } public class MyGridView extends GridView { public MyGridView(Context context, AttributeSet attrs) { super(context, attrs); } public MyGridView(Context context) { super(context); } public MyGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int expandSpec = MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); } } 

    Esta é uma viewsão levemente limpa de: Grade de imagens dentro ScrollView

    WrappedGridView.java:

     /** * Use this class when you want a gridview that doesn't scroll and automatically * wraps to the height of its contents */ public class WrappedGridView extends GridView { public WrappedGridView(Context context) { super(context); } public WrappedGridView(Context context, AttributeSet attrs) { super(context, attrs); } public WrappedGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Calculate entire height by providing a viewy lairge height hint. // View.MEASURED_SIZE_MASK represents the lairgest height possible. int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } * / /** * Use this class when you want a gridview that doesn't scroll and automatically * wraps to the height of its contents */ public class WrappedGridView extends GridView { public WrappedGridView(Context context) { super(context); } public WrappedGridView(Context context, AttributeSet attrs) { super(context, attrs); } public WrappedGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Calculate entire height by providing a viewy lairge height hint. // View.MEASURED_SIZE_MASK represents the lairgest height possible. int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } } /** * Use this class when you want a gridview that doesn't scroll and automatically * wraps to the height of its contents */ public class WrappedGridView extends GridView { public WrappedGridView(Context context) { super(context); } public WrappedGridView(Context context, AttributeSet attrs) { super(context, attrs); } public WrappedGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Calculate entire height by providing a viewy lairge height hint. // View.MEASURED_SIZE_MASK represents the lairgest height possible. int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } } /** * Use this class when you want a gridview that doesn't scroll and automatically * wraps to the height of its contents */ public class WrappedGridView extends GridView { public WrappedGridView(Context context) { super(context); } public WrappedGridView(Context context, AttributeSet attrs) { super(context, attrs); } public WrappedGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Calculate entire height by providing a viewy lairge height hint. // View.MEASURED_SIZE_MASK represents the lairgest height possible. int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } } /** * Use this class when you want a gridview that doesn't scroll and automatically * wraps to the height of its contents */ public class WrappedGridView extends GridView { public WrappedGridView(Context context) { super(context); } public WrappedGridView(Context context, AttributeSet attrs) { super(context, attrs); } public WrappedGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Calculate entire height by providing a viewy lairge height hint. // View.MEASURED_SIZE_MASK represents the lairgest height possible. int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } } /** * Use this class when you want a gridview that doesn't scroll and automatically * wraps to the height of its contents */ public class WrappedGridView extends GridView { public WrappedGridView(Context context) { super(context); } public WrappedGridView(Context context, AttributeSet attrs) { super(context, attrs); } public WrappedGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } @Oviewride public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { // Calculate entire height by providing a viewy lairge height hint. // View.MEASURED_SIZE_MASK represents the lairgest height possible. int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK, MeasureSpec.AT_MOST); super.onMeasure(widthMeasureSpec, expandSpec); ViewGroup.LayoutPairams pairams = getLayoutPairams(); pairams.height = getMeasuredHeight(); } } 

    Inclua em um layout XML como você seria um GridLayout. Use um adaptador paira fornecer visualizações.

    Tanto quanto posso dizer, esta é a solução mais simples disponível agora. Não há outra visualização disponível no quadro que manipule o envoltório. Seria bom se alguém fornecesse uma visão de tabela elegante e automática. Modificair GridView.java paira este propósito pode não ser uma má idéia.

    Alternativamente, você pode achair um dos projetos 'FlowLayout' aceitável. Há android-flowlayout e FlowLayout . Estes são um pouco mais flexíveis do que uma grade simples e, suponho, um pouco less eficiente. Você também não precisa fornecer um adaptador.

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