2014-09-25 1 views
0

Я пытаюсь создать макет для простой версии игры MasterMind. Я установил TableLayout с 10 TableRows с одинаковым вертикальным весом для представления колышек и последней большой строкой внизу. Каждый из основных 10 рядов состоит из 4 элементов Button (равного веса) и двух видов по бокам, так что кнопки остаются центрированными. У меня уже есть макет, который, как мне кажется, должен работать, но в настоящее время будет отображаться только 9 строк (остальные существуют, только за пределами экрана).Android TableLayout не отображает все 11 TableRows

Может кто-нибудь помочь мне понять, почему не все элементы отображаются? Я бы сделал серию LinearLayouts, но я слышал, что это не очень эффективно, хотя я не уверен, что мой текущий метод тоже.

Я в надежде получить что-то вдоль линий этого: 11 rows

но вместо я получаю это: Actual layout result

Вот макет (извините, что длинно/повторяющийся):

<?xml version="1.0" encoding="utf-8"?> 

<TableLayout 
    android:id="@+id/game_layout" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#b3b3b3" 
    android:orientation="vertical"> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 
     <Button 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="1"/> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:layout_weight="2" 
     android:orientation="horizontal"> 

     <View 
      android:layout_height="fill_parent" 
      android:layout_width="0dp" 
      android:layout_weight="2"/> 

    </TableRow> 

</TableLayout> 
+0

положить в прокрутку. – Meenal

ответ

2

Encase все дело в:

<ScrollView 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:scrollbars="none" 
    android:layout_weight="1"> 
    <TableLayout 
    android:id="@+id/game_layout" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#b3b3b3" 
    android:orientation="vertical"> 
    ... 

</ScrollView> 
+0

спасибо! – aProperFox