2015-08-31 36 views
0

我知道有一些问题具有相同的问题,但它们都不适用于我。这是我的xml:ScrollView只能托管一个直接孩子,但我只有一个

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:layout_weight="1"> 

<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="vertical" 
    android:background="@drawable/hatter"> 
    <TableLayout 
     android:id="@+id/TableLayout1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="30dp" 
     android:layout_marginRight="30dp" 
     android:stretchColumns="0" 
     tools:context="hu.szada.examplefortable.MainActivity" > 

     <RelativeLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="top"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="Szint 1" 
       android:textSize="30dp" 
       android:layout_centerHorizontal="true" 
       android:textColor="#12222a" /> 
     </RelativeLayout> 

     <TableRow 
      android:id="@+id/TableRow1" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/ajandekboltbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/ajandekbolt" /> 
       <ImageView 
        android:id="@+id/ajandekboltpipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     // ROW 2 

     <TableRow 
      android:id="@+id/TableRow2" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/akciofilmbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/akciofilm" /> 
       <ImageView 
        android:id="@+id/akciofilmpipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 3 

     <TableRow 
      android:id="@+id/TableRow3" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/babakocsibutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/babakocsi" /> 
       <ImageView 
        android:id="@+id/babakocsipipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 4 

     <TableRow 
      android:id="@+id/TableRow4" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/csirkefogobutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/csirkefogo" /> 
       <ImageView 
        android:id="@+id/csirkefogopipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 5 

     <TableRow 
      android:id="@+id/TableRow5" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/elemlampabutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/elemlampa" /> 
       <ImageView 
        android:id="@+id/elemlampapipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 6 

     <TableRow 
      android:id="@+id/TableRow6" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/evkonyvbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/evkonyv" /> 
       <ImageView 
        android:id="@+id/evkonyvpipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 7 

     <TableRow 
      android:id="@+id/TableRow7" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/foghazbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/foghaz" /> 
       <ImageView 
        android:id="@+id/foghazpipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 8 

     <TableRow 
      android:id="@+id/TableRow8" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/foldgombbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/foldgomb" /> 
       <ImageView 
        android:id="@+id/foldgombpipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 9 

     <TableRow 
      android:id="@+id/TableRow9" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/franciaagybutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/franciaagy" /> 
       <ImageView 
        android:id="@+id/franciaagypipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 10 

     <TableRow 
      android:id="@+id/TableRow10" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/gyongyszembutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/gyongyszem" /> 
       <ImageView 
        android:id="@+id/gyongyszempipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 11 

     <TableRow 
      android:id="@+id/TableRow11" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/gyujtozsinorbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/gyujtozsinor" /> 
       <ImageView 
        android:id="@+id/gyujtozsinorpipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 12 

     <TableRow 
      android:id="@+id/TableRow12" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/hatszogbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/hatszog" /> 
       <ImageView 
        android:id="@+id/hatszogpipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 13 

     <TableRow 
      android:id="@+id/TableRow13" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/kartyavarbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/kartyavar" /> 
       <ImageView 
        android:id="@+id/kartyavarpipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 14 

     <TableRow 
      android:id="@+id/TableRow14" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/kulonosbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/kulonos" /> 
       <ImageView 
        android:id="@+id/kulonospipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 15 

     <TableRow 
      android:id="@+id/TableRow15" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/szarkalabbutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/szarkalab" /> 
       <ImageView 
        android:id="@+id/szarkalabpipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 

     //ROW 16 

     <TableRow 
      android:id="@+id/TableRow16" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_marginTop="30dp" 
      android:layout_alignParentRight="true" > 

      <RelativeLayout android:layout_height="wrap_content" 
       android:layout_width="wrap_content"> 

       <ImageButton 
        android:id="@+id/tollseprubutton" 
        android:layout_width="match_parent" 
        android:layout_height="130dp" 
        android:background="@drawable/tollsepru" /> 
       <ImageView 
        android:id="@+id/tollseprupipa" 
        android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:layout_centerHorizontal="true" 
        android:layout_centerVertical="true" 
        android:src="@drawable/pipalista" 
        android:visibility="invisible"/> 
      </RelativeLayout> 
     </TableRow> 
    </TableLayout> 

</LinearLayout> 
</ScrollView> 

我只有一个孩子,这是一个LinearLayout,在布局中我有其他视图。我不知道我的代码中有什么问题。

+1

您还没有已关闭你试图清理项目 – gmetax

+0

了滚动标签? – George

+0

对不起,我错过了代码的结束,但我已经破坏了SrollView。 –

回答

0

我有同样的问题。由于这个Layoutfile不会抛出错误,但是由于另一个提供了ViewGroup。我假设你正在添加一个片段(与该布局文件)到一个活动。 我的错是我添加了一个片段到已经是ScrollView的ViewGroup。因此我Activity上的ScrollView有2个后代。

解决方案:包装上的活动在你的滚动型的FrameLayout,那么你的片段添加到FrameLayout里

相关问题