2015-12-31 35 views
2

我必須創建表格,如下圖所示在我的應用程序中。什麼是最好的方式來做到這一點?最佳可能的方式在Android中添加表格

我該如何創建一個這樣的表?任何教程? 你會選擇添加此表的哪種方法? 我要顯示該表告訴我最好的解決方案

另一個問題

假設,如果我在應用中添加這個形象,我如何添加縮放功能?任何教程?

enter image description here

+0

您是否試過TableLayout? – Eenvincible

+1

@Eenvincible是的,但其安靜的複雜,通過TableLayout添加如此多的數據 –

+0

你是否已經瞭解到有關Adpaters或RecyclerView的任何內容?如果是的話,你需要做第一行和第二個爲你將適配器,並與更多的數據; - ) – piotrek1543

回答

0

使用的表的佈局和使用也增加了利潤/邊境查看看看下面的代碼。重複<TableRow>添加更多行

<RelativeLayout 
    android:id="@+id/content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/appBar2" 
    android:paddingBottom="55dp" 
    android:paddingLeft="2dp" 
    android:paddingRight="2dp" 
    android:paddingTop="5dp" 
    tools:context=".MainActivity"> 

    <ScrollView 
     android:id="@+id/scrollView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content"> 

     <TableLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content"> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:background="#000000" /> 

      <TableRow> 
       <!-- Set the width to 0dp and set layout_weight=1! on both Views--> 
       <View 
        android:layout_width="1dp" 
        android:layout_height="match_parent" 
        android:background="#000000" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="2" 
        android:gravity="center" 
        android:text="DATE" 
        android:textColor="#000000" 
        android:textStyle="bold" /> 

       <View 
        android:layout_width="1dp" 
        android:layout_height="match_parent" 
        android:background="#000000" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="2" 
        android:gravity="center" 
        android:text="DAYS" 
        android:textColor="#000000" 
        android:textStyle="bold" /> 

       <View 
        android:layout_width="1dp" 
        android:layout_height="match_parent" 
        android:background="#000000" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="1" 
        android:gravity="center" 
        android:text="NO OF DAYS" 
        android:textColor="#000000" 
        android:textStyle="bold" /> 

       <View 
        android:layout_width="1dp" 
        android:layout_height="match_parent" 
        android:background="#000000" /> 

       <TextView 
        android:layout_width="0dp" 
        android:layout_height="wrap_content" 
        android:layout_weight="3" 
        android:gravity="center" 
        android:text="EVENT" 
        android:textColor="#000000" 
        android:textStyle="bold" /> 

       <View 
        android:layout_width="1dp" 
        android:layout_height="match_parent" 
        android:background="#000000" /> 
      </TableRow> 

      <View 
       android:layout_width="match_parent" 
       android:layout_height="1dp" 
       android:background="#000000" /> 
     </ScrollView> 
    </RelativeLayout> 
相關問題