我有一个LinearLayout,它带有一些在ScrollView中的元素。 现在我希望在屏幕底部有一个按钮(不在滚动视图的底部),它始终显示在前面,同时滚动此布局的其余内容。我怎样才能做到这一点?在LinearLayout中显示按钮始终在滚动时在屏幕的底部
这是我的滚动型:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:background="#e2e2e2">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/bgnLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
layout="@layout/trElement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp" />
<LinearLayout
android:id="@+id/stopslayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="16dp"
android:showDividers="middle"
android:divider="@drawable/divider">
</LinearLayout>
</LinearLayout>
</ScrollView>
和多数民众赞成在我加入我现在的按钮的代码部分(总是在滚动型的底部所示):
Button mpbtn = ButtonFactory.makeButton(m, R.string.openMap, R.color.AndroidBlue);
LinearLayout bgnLayout = (LinearLayout) rootView.findViewById(R.id.bgnLayout);
bgnLayout.addView(mpbtn);
我欣赏任何帮助。
为什么不只是在xml的底部添加按钮? – Sid 2015-04-01 08:49:22