我的ScrollView包含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 :(得分:0)
试试这样:
我认为布局视图工作正常并尝试下面的代码,
LayoutInflater inflater = context.getLayoutInflater();
View rowView=inflater.inflate(R.layout.layout_list, null, true);