2011-05-16 19 views
0

enter image description here爲什麼tablelayout的layout_width和_height沒有覆蓋三星平板電腦屏幕的整個區域?

喜的,

我已經在XML文件

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 
    <TableLayout 
     android:layout_width="fill_parent" android:layout_height="fill_parent" 
     android:id="@+id/tl_splash_screen" > 
     </TableLayout> 
</LinearLayout> 

,並在Java文件

TableLayout tl_splash_screen; 
    int int_scr_wd; 
    TableRow tr_test; 
    TextView txt_test; 
    TableRow tr_test1; 
    TextView txt_test1; 
    TableRow tr_test2; 
    TextView txt_test2; 
    TableRow tr_test3; 
    TextView txt_test3; 
    TableRow tr_test4; 
    TextView txt_test4; 
    TableRow tr_test5; 
    TextView txt_test5; 
    int int_tb_bk_col; 
    int int_black; 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.x_splash_screen); 
     try 
     { 
      txt_test=new TextView(this); 
      txt_test1=new TextView(this); 
      txt_test2=new TextView(this); 
      txt_test3=new TextView(this); 
      txt_test4=new TextView(this); 
      txt_test5=new TextView(this); 

      LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(int_scr_wd+300, LayoutParams.FILL_PARENT); 

      tr_test = (TableRow) new TableRow(this); 
      tr_test1 = (TableRow) new TableRow(this); 
      tr_test2 = (TableRow) new TableRow(this); 
      tr_test3 = (TableRow) new TableRow(this); 
      tr_test4 = (TableRow) new TableRow(this); 
      tr_test5 = (TableRow) new TableRow(this); 

      tl_splash_screen = (TableLayout)findViewById(R.id.tl_splash_screen); 

      int_tb_bk_col = Color.rgb(211,211,211); 
      int_black = Color.rgb(0,0,0); 

      tl_splash_screen.setBackgroundColor(int_tb_bk_col); 

      txt_test.setTextColor(int_black); 
      txt_test1.setTextColor(int_black); 
      txt_test2.setTextColor(int_black); 
      txt_test3.setTextColor(int_black); 
      txt_test4.setTextColor(int_black); 
      txt_test5.setTextColor(int_black); 

      Display display = getWindowManager().getDefaultDisplay(); 
      int_scr_wd= display.getWidth(); 
      int as = display.getHeight(); 
      Log.i("", String.valueOf(int_scr_wd)); 
      Log.i("", String.valueOf(as)); 

      txt_test1.setHeight(120); 
      txt_test2.setHeight(120); 
      txt_test3.setHeight(120); 
      txt_test4.setHeight(120); 
      txt_test5.setHeight(120); 

      txt_test.setText("TextViews"); 
      txt_test1.setText("- TextView 1"); 
      txt_test2.setText("- TextView 2"); 
      txt_test3.setText("- TextView 3"); 
      txt_test4.setText("- TextView 4"); 
      txt_test5.setText("- TextView 5"); 

      tr_test.addView(txt_test);   
      tr_test1.addView(txt_test1);    
      tr_test2.addView(txt_test2);    
      tr_test3.addView(txt_test3);    
      tr_test4.addView(txt_test4);    
      tr_test5.addView(txt_test5);    

      tl_splash_screen.addView(tr_test,new TableLayout.LayoutParams(layoutParams)); 
      tl_splash_screen.addView(tr_test1,new TableLayout.LayoutParams(layoutParams)); 
      tl_splash_screen.addView(tr_test2,new TableLayout.LayoutParams(layoutParams)); 
      tl_splash_screen.addView(tr_test3,new TableLayout.LayoutParams(layoutParams)); 
      tl_splash_screen.addView(tr_test4,new TableLayout.LayoutParams(layoutParams)); 
      tl_splash_screen.addView(tr_test5,new TableLayout.LayoutParams(layoutParams)); 
     } 
     catch(Exception ex) 
     { 
      Log.i("caught error","caught while loading main page"); 
     } 
    } 

只是爲了證明我已經發布這個寫這樣的事情碼。大家可以看到我提到了textview 5,其中「textview - 5」文本被寫入,因爲我沒有在可滾動視圖下使用tablelayout,因此屏幕上不可見。

所有我想問,爲什麼表格佈局覆蓋屏幕的某些區域,即使我已經定義了fill_parent。

請提出建議。

回答

1

<supports-screens android:smallScreens="true" android:normalScreens="true" android:largeScreens="true" android:anyDensity="false" />

添加到您的清單文件。

+0

thanx很多..好的 – Sourabh 2011-05-16 11:44:21

相關問題