【发布时间】:2015-06-05 19:57:37
【问题描述】:
我有一个带有一些元素的 LinearLayout,它位于 ScrollView 中。 现在我想在屏幕底部有一个按钮(而不是在 ScrollView 的底部),它总是显示在前面,同时滚动这个布局的其余内容。我怎样才能做到这一点?
这是我的滚动视图:
<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>
这就是代码中我添加当前按钮的部分(始终显示在 ScrollView 的底部):
Button mpbtn = ButtonFactory.makeButton(m, R.string.openMap, R.color.AndroidBlue);
LinearLayout bgnLayout = (LinearLayout) rootView.findViewById(R.id.bgnLayout);
bgnLayout.addView(mpbtn);
感谢您的帮助。
【问题讨论】:
-
为什么不直接在xml底部添加按钮?
标签: android android-layout scrollview