0

是否有任何選項可以將元素放置在可擴展列表下方,讓我解釋一下:我已經實現了列表下方的元素,但它們的行爲類似於頁腳 - 浮動在屏幕底部。可擴展列表下方的元素 - 不是浮動頁腳

但是,如果我把元素放在xml列表的下面,當任何組展開時元素都會隱藏起來。

此刻我的佈局行爲像這樣

http://shrani.si/f/2s/ba/ga2VKfi/lay2.jpg

,但我想是這樣的,在該列表的末尾

http://shrani.si/f/42/4m/2GAcNu6T/lay3.jpg

我此刻

佈局
<LinearLayout 
       android:id="@+id/linearLayoutListExer" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dip" 
       android:background="#ffffff" 
       android:gravity="center_vertical" 
       android:orientation="vertical"> 

       <ExpandableListView 
        android:id="@+id/ExerciseELV" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@+id/linearLayoutStatus" 
        android:layout_weight="1" 
        android:groupIndicator="@null" /> 

       <LinearLayout 
        android:id="@+id/relativeFooter" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_below="@id/linearLayoutListExer" 

        android:background="#ffffff" 
        android:orientation="vertical"> 

        <TextView 
         android:id="@+id/textViewBellowExercise" 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:padding="10dip" 
         android:text="The following exercises will help you lose body weight" 
         android:textAppearance="?android:attr/textAppearanceSmall" 

         /> 

        <LinearLayout 
         android:layout_width="fill_parent" 
         android:layout_height="wrap_content" 
         android:layout_below="@id/textViewBellowExercise"> 


         <Button 
          android:id="@+id/buttonFaceit" 
          android:layout_width="0dp" 
          android:layout_height="20dp" 
          android:layout_margin="5dp" 
          android:layout_weight="1" 
          android:background="@color/green" 
          android:text="FaceIT!" 
          android:textColor="@color/white" /> 

         <Button 
          android:id="@+id/buttonChallenge" 
          android:layout_width="0dp" 
          android:layout_height="20dp" 
          android:layout_margin="5dp" 
          android:layout_weight="1" 
          android:background="@color/red" 
          android:text="Challenge" 
          android:textColor="@color/white" /> 
        </LinearLayout> 
       </LinearLayout> 
      </LinearLayout> 

回答

1

您的以下財產應該改變。 而不是 android:layout_below="@id/linearLayoutListExer"

你應該寫 android:layout_below="@id/ExerciseELV"

爲的LinearLayout與android:id="@+id/relativeFooter"

這將使底部佈局出現在列表視圖下方

+0

你的解決方案固定我的頁腳在屏幕的底部,但這不是我想要實現的。我希望它在名單下方,當我擴大1組項目時,我想將頁腳壓低。目前擴大的名單被推到波紋管的底部,當擴大。 – gregaj

+1

你說:「此時擴展列表被推到下面的頁腳,擴展時」。一個小的更正。該列表永遠不會被推到任何地方。列表視圖旨在顯示最前面的最小項目,但在滾動時顯示其他隱藏項目。你的group4內容已經越過了顯示的限制,因此它隱藏在幕後。相同的代碼將完美適用於平板電腦(只要列表內容保持不變)。但是對於移動設備,您需要修改佈局方法。 – Vansi

+0

對不起,誤解,你的解決方案工作正常,但它不是我所期待的,我最終使用「addfooterview」方法,它工作正常。 – gregaj

0

我是新到Android所以我對於我可能會問的任何「愚蠢」的問題,感到抱歉。

我結束了使用addfooterview方法,它很好。

您需要在自己的xml中分隔頁腳佈局,然後使其膨脹並將其添加到可展開的列表視圖。

View footer=inflater.inflate(R.layout.activity_main_footer,null); 
    elv.addFooterView(footer);