首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Admob + TableLayout + ScrollView = TableLayout不出现

Admob + TableLayout + ScrollView = TableLayout不出现
EN

Stack Overflow用户
提问于 2014-03-01 14:55:24
回答 1查看 90关注 0票数 0

我的应用程序起作用了(我的TableLayout出现了),但是当我把Admod广告放在底部时,我就会面临这个问题。我的广告出现了,但TableLayout没有出现。我的xml:

代码语言:javascript
复制
<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>

我的MainActivity.java:

代码语言:javascript
复制
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();
                    } 
          }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-03-02 02:08:48

您的LinearLayout已被配置为使用分配给它的父级的整个空间。改为:

代码语言:javascript
复制
 <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>
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22115886

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档