Question

My app worked(my TableLayout appears) but I when I put the Admod Ads at the bottom I face the problem. My ads appear but the TableLayout doesn't appear.. my xml:

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_above="@+id/prueba">
<ScrollView 
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_above="@+id/linearLayout"
    >

    <TableLayout 

    android:id="@+id/myTableLayout"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
     >
    </TableLayout>

         </ScrollView>
 <LinearLayout
              android:id="@+id/linearLayout"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="match_parent"
              android:layout_alignParentBottom="true"
              android:layout_gravity="bottom"
              >
              </LinearLayout>

</RelativeLayout>

my MainActivity.java:

for (int i= 0; i<listaPartidos.size();i++){

                        if((listaPartidos.get(i).getFecha().equals("a"))){

                    TableRow tr = new TableRow(MainActivity.this);
                    tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));

                    TextView competicion = new TextView(MainActivity.this);
                    competicion.setText(listaPartidos.get(i).getCompeticion());
                    competicion.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                    competicion.setTextSize(10);
                    competicion.setTypeface(null, Typeface.ITALIC);

                    TextView equipoLocal= new TextView(MainActivity.this);
                    equipoLocal.setText(listaPartidos.get(i).getEquipoLocal());
                    equipoLocal.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                    equipoLocal.setTextSize(10);
                    equipoLocal.setGravity(17);
                    equipoLocal.setTypeface(null, Typeface.BOLD);
                    System.out.println(listaPartidos.get(i).getEquipoLocal());

                    TextView guion= new TextView(MainActivity.this);
                    guion.setText(listaPartidos.get(i).getGuion());
                    guion.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                    guion.setTextSize(10);
                    guion.setGravity(17);
                    guion.setTypeface(null, Typeface.BOLD);

                    TextView equipoVisitante= new TextView(MainActivity.this);
                    equipoVisitante.setText(listaPartidos.get(i).getEquipoVisitante()+ "                    ");
                    equipoVisitante.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                    equipoVisitante.setTextSize(10);
                    equipoVisitante.setGravity(17);
                    equipoVisitante.setTypeface(null, Typeface.BOLD);

                    TableRow tr2 = new TableRow(MainActivity.this);
                    TableRow.LayoutParams rowSpanLayout = new TableRow.LayoutParams(
                    TableRow.LayoutParams.FILL_PARENT, TableRow.LayoutParams.WRAP_CONTENT);
                    tr2.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                    rowSpanLayout.span = 2;
                    TextView canal= new TextView(MainActivity.this);
                    canal.setText(listaPartidos.get(i).getCanal());
                    canal.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                    canal.setTextSize(10);

                    TextView hora= new TextView(MainActivity.this);
                    hora.setText(listaPartidos.get(i).getHora());
                    hora.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                    hora.setTextSize(10);
                    hora.setGravity(3);
                    if(i%2==0){
                        competicion.setBackgroundColor(Color.LTGRAY);
                        hora.setBackgroundColor(Color.LTGRAY);
                        guion.setBackgroundColor(Color.LTGRAY);
                        canal.setBackgroundColor(Color.LTGRAY);
                        equipoLocal.setBackgroundColor(Color.LTGRAY);
                        equipoVisitante.setBackgroundColor(Color.LTGRAY);
                    }
                    tr.addView(competicion);
                    tr.addView(equipoLocal);
                    tr.addView(guion);
                    tr.addView(equipoVisitante);
                    tr2.addView(canal, rowSpanLayout);
                    tr2.addView(hora, rowSpanLayout);
                    TableLayout tl = (TableLayout)findViewById(R.id.myTableLayout);
                    tl.addView(tr,new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT , LayoutParams.WRAP_CONTENT));
                    tl.addView(tr2,new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT , LayoutParams.WRAP_CONTENT));

                    }else{
                        TableRow tr = new TableRow(MainActivity.this);
                        tr.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                        TextView fecha = new TextView(MainActivity.this);
                        fecha.setText(listaPartidos.get(i).getFecha());
                        fecha.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
                        fecha.setTextSize(11);
                        fecha.setTypeface(null, Typeface.BOLD);
                        fecha.setTextColor(Color.RED);
                        tr.addView(fecha);

                        TableLayout tl = (TableLayout)findViewById(R.id.myTableLayout);
                        tl.addView(tr,new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT , LayoutParams.WRAP_CONTENT));
                    }
                    }

                    //setContentView(R.layout.activity_main);
                    Toast.makeText(MainActivity.this, "Tarea finalizada!", Toast.LENGTH_SHORT).show();
                    } 
          }
Was it helpful?

Solution

You LinearLayout has been configured to consume the entire space allocated to it's parent. Change it to:

 <LinearLayout
              android:id="@+id/linearLayout"
              android:orientation="vertical"
              android:layout_width="match_parent"
              android:layout_height="wrap_content"
              android:layout_alignParentBottom="true"
              android:layout_gravity="bottom"
              >
              </LinearLayout>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top