2015-12-31 30 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> 
相关问题