2015-06-18 24 views
1

我有滾動型用的LinearLayout和按鈕內:動態內容失去了最後一個視圖

<ScrollView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

    <LinearLayout 
     android:id="@+id/layout_scroll" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:id="@+id/layout_list" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="10dp" 
      android:background="@color/card_color" 
      android:orientation="vertical" 
      android:padding="10dp"> 

     </LinearLayout> 

     <Button 
      android:id="@+id/button_leave" 

      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="10dp" 
      android:text="@string/leave" /> 

    </LinearLayout> 
</ScrollView> 

然後在代碼中,我添加視圖layout_list

View view = LayoutInflater.from(this) 
     .inflate(R.layout.item_member, mLayoutMemberList, true); 

如果我添加不許多項目,然後button_leave是可見的。但是,如果我添加了很多項目(更多然後顯示在屏幕上),那麼即使向下滾動,按鈕在屏幕上也不可見。

更新:

看起來它是android.support.design.widget.CoordinatorLayout錯誤。我將其更改爲簡單的線性佈局,並且所有工作都很好。

+0

可以請你嘗試改變父母的LinearLayout的高度來匹配父,它是目前包裝電流。 'android:layout_height =「wrap_content」' – AAnkit

+0

不幸的是它沒有幫助,它提供者lint警告:應該使用wrap_content。 – HotIceCream

回答

0

嘗試這樣的:

我覺得佈局視圖中工作正常,並嘗試下面的代碼,

LayoutInflater inflater = context.getLayoutInflater(); 
View rowView=inflater.inflate(R.layout.layout_list, null, true);