在scroll下面固定Button的方法

1 <ScrollView
2 android:layout_height="0dp"
3 android:id="@+id/scrollView1"
4 android:layout_width="match_parent"
5 android:layout_weight="8"
6 >
 1 </ScrollView>    
 2             <LinearLayout
 3                 android:layout_height="0dp" 
 5                 android:layout_width="match_parent"
 6                 android:orientation="vertical"
 7                 android:background="@color/black"
 8                 android:layout_weight="1"
 9             >
10                 <Button
11                     android:id="@+id/btregist"
12                     android:layout_height="wrap_content"
13                     android:layout_width="match_parent"
14                     android:background="@drawable/regist_button"
15                     android:layout_gravity="bottom"
16                 ></Button>
17             </LinearLayout>
复制代码
第二种办法:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <RelativeLayout
 3     xmlns:android="http://schemas.android.com/apk/res/android"
 4     android:layout_width="fill_parent"
 5     android:layout_height="fill_parent"
 6     
 7 >
 8     <ScrollView
 9         android:layout_height="fill_parent"
10         android:id="@+id/scrollView1"
11         android:layout_width="match_parent"
12         android:layout_above="@+id/llybuttom">
14        <!--此处各种内容 -->
15     </ScrollView>
16     <LinearLayout
17             android:layout_height="wrap_content"
18             android:id="@+id/llybuttom"
19             android:layout_width="match_parent"
20             android:orientation="vertical"
21             android:layout_alignParentBottom="true" 
22         >
23             <Button
24                 android:id="@+id/btregist"
25                 android:layout_height="wrap_content"
26                 android:layout_width="match_parent"
27                 android:background="@drawable/regist_button"
28                 android:layout_gravity="bottom"
29             ></Button>
30     </LinearLayout>    
31 </RelativeLayout>

http://www.cnblogs.com/huangquanhj/archive/2012/11/30/2795989.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您好!对于vue-seamless-scroll组件的部分固定,您可以通过以下步骤实现: 1. 首先,确保您已经安装了vue-seamless-scroll组件并成功引入到您的项目中。 2. 在您需要部分固定的地方,可以使用CSS的position属性来实现。例如,如果您需要固定在顶部,可以将该元素的position属性设置为fixed,并设置top属性为0。 3. 在vue-seamless-scroll组件中,找到需要固定的部分的相应位置。 4. 使用Vue的计算属性或者绑定class的方式,根据滚动状态来动态添加或移除固定样式。例如,可以使用v-bind:class指令来绑定一个计算属性,根据滚动状态返回相应的class。 5. 在计算属性中,通过监听滚动事件来判断滚动条的位置,根据需要添加或移除固定样式。 以下是一个示例代码: ```html <template> <div class="scroll-container"> <div class="fixed-header" :class="{ 'fixed': isFixed }">部分固定内容</div> <vue-seamless-scroll :list="list"></vue-seamless-scroll> </div> </template> <script> export default { data() { return { list: [...yourDataList], isFixed: false, }; }, computed: { scrollContainer() { return document.querySelector('.scroll-container'); }, }, mounted() { this.scrollContainer.addEventListener('scroll', this.handleScroll); }, beforeDestroy() { this.scrollContainer.removeEventListener('scroll', this.handleScroll); }, methods: { handleScroll() { const scrollTop = this.scrollContainer.scrollTop; // 根据需要修改滚动位置的阈值 if (scrollTop >= 100) { this.isFixed = true; } else { this.isFixed = false; } }, }, }; </script> <style scoped> .scroll-container { position: relative; /* 设置滚动容器的高度和宽度 */ } .fixed-header { position: absolute; top: 0; left: 0; width: 100%; /* 设置固定部分的样式 */ } .fixed { /* 添加固定样式 */ } </style> ``` 请根据您具体的需求进行调整,这是一个基本的示例,您可以根据实际情况进行适配。希望对您有所帮助!如果您还有其他问题,请继续提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值