一、样例一:15个按钮竖直排列,一般的屏幕不可能全部显示,得用ScrollView滚动界面。

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:orientation="vertical"android:id="@+id/id_scrollView"android:layout_width="fill_parent"android:layout_height="fill_parent"android:scrollbars="vertical"android:background="@drawable/background"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button1" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button2" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button3" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button4" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button5" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button6" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button7" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button8" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button9" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button10" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button11" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button12" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button13" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button14" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button15" /></LinearLayout>
</ScrollView>

二、样例二,跟样例一差不多一样,只是在滚动的时候有一个控件(id/time)不跟着滚动,一直浮在最上面。

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:background="@drawable/background"><ScrollViewandroid:id="@+id/id_scrollView"android:layout_width="fill_parent"android:layout_height="fill_parent"android:scrollbars="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button1" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button2" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button3" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button4" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button5" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button6" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button7" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button8" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button9" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button10" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button11" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button12" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button13" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button14" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button15" /></LinearLayout></ScrollView><TextViewandroid:id="@+id/time"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1"android:textSize="14dp"android:textColor="#F30606"android:gravity="center"android:text="2022-03-09 15:29" /></RelativeLayout>

三、样例三,滚动的内容由两部分组成,详细效果看下面的gif。

<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"><ScrollViewandroid:id="@+id/id_scrollView"android:layout_width="fill_parent"android:layout_height="fill_parent"android:scrollbars="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"android:background="@drawable/background"><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button1" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button2" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button3" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button4" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button5" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button6" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button7" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button8" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button9" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button10" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button11" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button12" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button13" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button14" /><Buttonandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="Button15" /></LinearLayout><LinearLayoutandroid:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"android:background="@drawable/girl"><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView1" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView2" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView3" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView4" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView5" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView6" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView7" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView8" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView9" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView10" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView11" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView12" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView13" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView14" /><TextViewandroid:layout_width="match_parent"android:layout_height="wrap_content"android:layout_marginTop="20dp"android:text="TextView15" /></LinearLayout></LinearLayout></ScrollView><TextViewandroid:id="@+id/time"android:layout_width="fill_parent"android:layout_height="wrap_content"android:layout_weight="1"android:textSize="14dp"android:textColor="#F30606"android:gravity="center"android:text="2022-03-09 15:29" /></RelativeLayout>

四、参考文章

Android布局 ScrollView滚动界面 - 简书

https://www.jb51.net/article/120767.htm

2022-03-09 Android布局 ScrollView滚动界面相关推荐

  1. Android对ScrollView滚动监听,实现美团、大众点评的购买悬浮效果

    Android对ScrollView滚动监听,实现美团.大众点评的购买悬浮效果 转:http://blog.csdn.net/xiaanming/article/details/17374599 很荣 ...

  2. android登陆页布局,Android布局Skype登录界面实例

    郑州app开发Android布局Skype登录界面,下面是布局的代码: {?xml version="1.0" encoding="utf-8"?} {Line ...

  3. Android之ScrollView滚动布局控件使用以及显示新闻网页

    ScrollView滚动布局使用原理: ①滚动产生的条件是,里面的内容大于物理尺寸 ②ScrollView里面只有一个子元素,这个子元素就是一个线性布局LinearLayout,我们可以在线性布局中添 ...

  4. Android 对ScrollView滚动监听,实现美团、大众点评的购买悬浮效果

    转帖请注明本文出自xiaanming的博客(http://blog.csdn.net/xiaanming),请尊重他人的辛勤劳动成果,谢谢! 随着移动互联网的快速发展,它已经和我们的生活息息相关了,在 ...

  5. 安卓Android实现聊天滚动界面

    原帖: 跳转 Android实现聊天界面 更新时间:2018年06月13日 14:14:05   作者:Thierryxc   这篇文章主要为大家详细介绍了Android实现聊天界面的方法,具有一定的 ...

  6. android 滚动到底部,Android 控制ScrollView滚动到底部(示例代码)

    在开发中,我们经常需要更新列表,并将列表拉倒最底部,比如发表微博,聊天界面等等, 这里有两种办法,第一种,使用scrollTo(): public static void scrollToBottom ...

  7. Android 控制ScrollView滚动到底部

    在开发中,我们经常需要更新列表,并将列表拉倒最底部,比如发表微博,聊天界面等等, 使用fullScrol() 下面我们看一下这个函数: scrollView.fullScroll(ScrollView ...

  8. Android布局整合include界面控件 示例

    http://bbs.51cto.com/thread-958714-1.html 转载于:https://blog.51cto.com/creator0hacker/1246349

  9. android 布局总结

     转自http://www.apkbus.com/android-45156-1-1.html 本帖最后由 北小生 于 2012-5-11 02:10 编辑 01.jpg (27.68 KB, 下 ...

最新文章

  1. Yann LeCun:距离“真正的” AI,我们还缺什么?
  2. Efficiency / Relative Efficiency and the Efficient Estimator
  3. 运行一个Hadoop Job所需要指定的属性
  4. [Swagger2]SpringBoot集成Swagger
  5. html中如何设置几张图片在一个div里来回切换_从 B 站的秋季主题中学习 “图层组合动画”...
  6. python列表元祖字典集合运算_Python基础5:列表 元祖 字典 集合 Json
  7. 2019年江苏省计算机一级考试题目和答案,江苏省计算机等级考试一级2019年(春)...
  8. Comparable与Comparator异同
  9. MS SQL 语句中的字符串连接
  10. 为什么我tracert经过H3C设备的时候,老是*号,不回包
  11. tracert命令查询服务器位置,服务器管理中tracert命令常用原理和命令行详解
  12. struts2 拦截器返回值问题
  13. sumif单列求和_Sumif、Sumifs单列多条件求和-阿里云开发者社区
  14. 计算机ln代表什么意思,ln计算器(log计算器在线)
  15. 读《出梁庄记》乱摘2
  16. 序言页码(纯思维题)
  17. HTML5 CSS3 生日快乐动画网页(粉红色的回忆)
  18. 基于ICP算法的三维点云数据拼接算法的实现
  19. nessus安装及使用
  20. EasyRecovery是最好用的手机数据恢复工具

热门文章

  1. A7139无线驱动调试
  2. 计算机中64位和32位什么意思?有什么区别?
  3. 域名备案注销的简单方法
  4. ChatGPT研究报告:AIGC带来新一轮范式转移
  5. 百度云非 VIP如何作弊加速?
  6. 如何解决git代码冲突
  7. 惠普战66系列拆机图文详解
  8. 书评:《佐藤可士和的超整理术》
  9. SAS学习1(总体介绍以及一些程序例子)
  10. unity获取脚本组件_Unity脚本组件