如何让一个布局文件在活动底部,不随着滚动,是顶部和底部不滚动,中间滚动,
在w3chool上有关css有这样的例子
中间的控件放到一个 ScrollView 中就可以了、;
头尾固定,中间放可滚动的控件
整个页面父布局改成 relativeLayout 里面加一个 在底部或头部控件(定义为 topView)紧贴父布局头部 然后把之前写的(mainView)在below 在topView的下面就行了
综合采纳,上面几位也提到了,简单点用最外用个相对布局,相对父布局固定头尾布局栏,在中间加滑动控件,像你这问的应该上下滚动吧,就在中间加一个ScrollView就可以啦,注意:ScrollView包裹的直接子布局或控件只能有一个……希望对你有用
把头部和尾部放在scrollview外面,中间那部分全部用scrollview包起来
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="head"
android:padding="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<!-- 加相应的控件 -->
</LinearLayout>
</ScrollView>
<TextView
android:text="bottom"
android:padding="8dp"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
用 RelativeLayout先将你要固定的两个控件放置顶部和底部,中间用ScrollView,ScrollView里写一个布局,LinearLayout,你想滚动应该是要放ListView之类的控件吧,嗯 就是这样