2015-06-25 4 views
0

У меня в нижней части экрана две кнопки для следующих и предыдущих строк внутри таблицы в таблице, как показано ниже.Развернуть кнопку в TableRow

<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" 
tools:context="${relativePackage}.${activityClass}" > 


    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#000000" > 

     <TableLayout 
      android:id="@+id/table1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:background="#000000" 
      > 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:textColor="#FFFFFF" 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        /> 

       <TextView /> 

      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:textColor="#FFFFFF" 
        android:id="@+id/textView2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        /> 

      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       > 

       <ImageView 
        android:id="@+id/imageView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:scaleType="fitCenter" 
        android:adjustViewBounds="true" 
        android:visibility="gone" 
        /> 

       <ProgressBar 
        android:id="@+id/progressBar1" 
        style="?android:attr/progressBarStyleLarge" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:visibility="visible" 
        /> 

      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" > 
       <TextView 
        android:textColor="#FFFFFF" 
        android:id="@+id/textView3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        /> 
      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow5" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="fill" 
       > 


       <Button 
        android:id="@+id/next" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:onClick="goNext" 
        android:text="Next" /> 
      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow6" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" > 

       <Button 
        android:id="@+id/previous" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:onClick="goPrevious" 
        android:text="Previous" /> 

      </TableRow> 
     </TableLayout> 
    </ScrollView> 

</LinearLayout> 

Однако кнопки ниже и выше не заполняют строку. Я хочу развернуть обе кнопки, чтобы заполнить строку (родительскую)? Какие-либо предложения?

enter image description here

ответ

1

Использование Layout_weight для кнопок

<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" 
tools:context="${relativePackage}.${activityClass}" > 


    <ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#000000" > 

     <TableLayout 
      android:id="@+id/table1" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:background="#000000" 
      > 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow1" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:textColor="#FFFFFF" 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        /> 

       <TextView /> 

      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow2" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" > 

       <TextView 
        android:textColor="#FFFFFF" 
        android:id="@+id/textView2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        /> 

      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow3" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:gravity="center" 
       > 

       <ImageView 
        android:id="@+id/imageView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:scaleType="fitCenter" 
        android:adjustViewBounds="true" 
        android:visibility="gone" 
        /> 

       <ProgressBar 
        android:id="@+id/progressBar1" 
        style="?android:attr/progressBarStyleLarge" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:visibility="visible" 
        /> 

      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow4" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" > 
       <TextView 
        android:textColor="#FFFFFF" 
        android:id="@+id/textView3" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        /> 
      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow5" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:gravity="fill" 
       > 


       <Button 
        android:id="@+id/next" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:onClick="goNext" 
        android:layout_weight="1" 
        android:text="Next" /> 
      </TableRow> 

      <TableRow 
       android:background="#000000" 
       android:id="@+id/tableRow6" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" > 

       <Button 
        android:id="@+id/previous" 
        style="?android:attr/buttonStyleSmall" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:onClick="goPrevious" 
         android:layout_weight="1" 
        android:text="Previous" /> 

      </TableRow> 
     </TableLayout> 
    </ScrollView> 

</LinearLayout> 

Я изменил его копировать и вставлять Он будет работать Благодаря

0

Изменить TableRow layout_width="match_parent" вокруг кнопок

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