2016-05-23 32 views
0

我有一個名爲「網格」表,創建自己的類裏......這樣的:插入TableLayout與RelativeLayout的內部滾動條

ScrollView contentView = new ScrollView(this); 
     contentView.setBackgroundColor(Color.LTGRAY); 

     // THIS IS OUR MAIN LAYOUT 
     mainLayout = new RelativeLayout(this); 

     // ADD MAINLAYOUT TO SCROLLVIEW (contentView) 

     contentView.addView(mainLayout); 

     // SET CONTENT VIEW 

     setContentView(contentView); 

     meTable = this.tableLayout(); 

     HorizontalScrollView HOR = new HorizontalScrollView(this); 

     mainLayout.addView(HOR); 

     HOR.addView(meTable); 

這將創建表,並且還增加了水平和垂直滾動條,太好了......

不過,我需要把所有的這另一個RelativeLayout的裏面,像這樣:

enter image description here

I C在這樣做,但沒有滾動條,我只需要添加「meTable」,像這樣:

Grid gr = new Grid(); 
     gr.Activate(this); 
     TableLayout tablita; 

     RelativeLayout layout = (RelativeLayout) findViewById(R.id.contenedorLay); 

     tablita = gr.meTable; 


     layout.addView(tablita); 

如何與他們的滾動條添加整個表?

回答

0

看看這段代碼,它爲我工作:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" > 
<ScrollView 
    android:id="@+id/layout" 
    android:layout_height="match_parent"   
    android:scrollbars="horizontal|vertical" 
    android:layout_width="match_parent"  
    android:layout_marginTop="5dip"  
    android:scrollbarStyle="outsideInset" 
    android:fillViewport="true"> 

    <HorizontalScrollView 
     android:id="@+id/horizontalView" 
     android:layout_height="wrap_content"  
     android:scrollbars="horizontal|vertical" 
     android:layout_width="wrap_content"  
     android:layout_marginTop="5dip"> 

     <TableLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/tlGridTable" > 
     </TableLayout> 
    </HorizontalScrollView> 
</ScrollView> 
</LinearLayout> 
+1

誰知道你的爸爸? – WhiteFloater