2017-04-09 34 views
0

您好我有一個桌面佈局,在API 21 +上顯示效果很好,但不幸的是,當我嘗試在API 15上運行我的應用程序時,我得到的行空白並且完全拉伸,看不到任何信息,滾動,但我無法看到桌子上的任何想法?感謝您的幫助!TableLayout在API 15上無法正確顯示

XML:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" android:layout_height="match_parent" 
android:background="#3d455b"> 

<ScrollView 
    android:id="@+id/scrollView" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_alignParentLeft="true" > 

<HorizontalScrollView 
    android:id="@+id/hscrll1" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <RelativeLayout 
     android:id="@+id/RelativeLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical" > 

<TableLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/entries" 
    android:stretchColumns="*"> 

    <TableRow android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/row_cell"> 
    </TableRow> 

</TableLayout> 
    </RelativeLayout> 
</HorizontalScrollView> 
</ScrollView> 
</RelativeLayout> 

JAVA:

valuesTable.removeAllViews(); 

//add header 
     TableRow tbrow0 = new TableRow(ctx); 
     tbrow0.setLayoutParams(new LayoutParams(
       LayoutParams.MATCH_PARENT, 
       LayoutParams.WRAP_CONTENT)); 
     TextView tv0 = new TextView(ctx); 
     tv0.setText("Id"); 
     tv0.setTextSize(20); 
     tv0.setTextColor(Color.WHITE); 
     tv0.setPadding(10, 10, 10, 10); 
     tbrow0.addView(tv0); 
     TextView tv0 = new TextView(ctx); 
     tv0.setText("name"); 
     tv0.setTextSize(20); 
     tv0.setTextColor(Color.WHITE); 
     tv0.setPadding(10, 10, 10, 10); 
     tbrow0.addView(tv0); 
     TextView tv0 = new TextView(ctx); 
     tv0.setText("color"); 
     tv0.setTextSize(20); 
     tv0.setTextColor(Color.WHITE); 
     tv0.setPadding(10, 10, 10, 10); 
     tbrow0.addView(tv0); 


     valuesTable.addView(tbrow0); 

     //Add row information 

      TableRow tbrow = new TableRow(ctx); 
      tbrow.setLayoutParams(new LayoutParams(
        LayoutParams.MATCH_PARENT, 
        LayoutParams.WRAP_CONTENT)); 
      for(String value : row.getValues()){ 
       TextView t1v = new TextView(ctx);    
       t1v.setText(value); 
       t1v.setTextSize(17); 
       t1v.setTextColor(getResources().getColor(R.color.darkgray)); 
       t1v.setPadding(10, 10, 10, 10); 
       t1v.setGravity(Gravity.CENTER); 
       tbrow.addView(t1v); 
      } 

      valuesTable.addView(tbrow); 

回答

0

拆卸相對佈局滾動視圖內沒有爲舊的API的伎倆。