2013-02-28 2 views
0

У меня есть таблица внутри ScrollView будет один столбец, содержащий несколько кнопок. Моя цель - добавить заголовок в верхнюю часть столбца, так как вы прокручиваете вниз заголовок остается с вами.Создание статического заголовка таблицы с ScrollView

Я провел некоторое исследование по этому вопросу и попробовал такие вещи, как «фиктивный» ряд, но не уверен, как это сделать.

Вот что я до сих пор пытаюсь, но заголовок не перемещается вместе с вами при прокрутке. Спасибо заранее.

<?xml version="1.0" encoding="utf-8"?> 
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation='horizontal' > 


    <ScrollView 
     android:layout_width="wrap_content" 
     android:layout_height="200dp" > 


    <TableLayout android:id="@+id/table_left" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="left" > 

     <TableLayout 
      android:id="@+id/header" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" > 

     <TableRow> 
     <TextView android:id="@+id/header_tab1" 
      android:textColor="@android:color/black" 
      android:layout_weight="1" 
      android:gravity="center_horizontal" 
      android:text="Header_tb1" > 
      </TextView> 
     </TableRow> 
     </TableLayout> 

     <TableRow> 
     <TextView 
      android:layout_height="0dp" 
      android:layout_weight="1" 
      android:text="Header_tb1" >  
     </TextView> 
     </TableRow> 


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

      <Button 
       android:id="@+id/Button1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/Button1" 
       android:textSize="23sp" > 
      </Button> 
      </TableRow> 

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

       <Button android:id="@+id/Button2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/Button2" 
        android:textSize="23sp" > 
       </Button> 
      </TableRow> 

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

       <Button android:id="@+id/Button3" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/Button3" 
        android:textSize="23sp" > 
       </Button> 
      </TableRow> 

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

       <Button android:id="@+id/Button4" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/Button4" 
        android:textSize="23sp" > 
       </Button> 
      </TableRow> 

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

       <Button android:id="@+id/Button5" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/Button5" 
        android:textSize="23sp" > 
       </Button> 
      </TableRow> 

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

       <Button android:id="@+id/Button6" 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/Button6" 
        android:textSize="23sp" > 
       </Button> 
      </TableRow> 

     </TableLayout> 
     </ScrollView> 
     </LinearLayout> 

ответ

0

, если я понял ваш вопрос, вы можете создать один верхний вид снаружи прокрутки более макета таблицы и этот макет таблицы будет ваш заголовок таблицы ..

Смежные вопросы