Android开发
Android高级控件的使用:
ScrollView的使用方法:
1.改变这个布局文件的根布局:把根布局改成:ScrollView
注意:ScrollView的子元素只能有一个,所以得增加一个LinearLayout布局,把其他按键放在这个LinearLayout中,那么ScrollViewd的子元素就只有一个LinearLayout了,而LinearLayout的子元素不限制。
代码如下:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<Button
android:id="@+id/IVButton_Id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="跳转到ImageView"
android:textSize="20dp"
android:textAllCaps="false"/>
<Button
android:id="@+id/LVButton_Id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="跳转到ListView"
android:textSize="20dp"
android:textAllCaps="false"/>
<Button
android:id="@+id/GVButton_Id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="跳转到GridView"
android:textSize="20dp"
android:textAllCaps="false"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮1"
android:textSize="20dp"
android:textAllCaps="false"
android:layout_marginTop="100dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮2"
android:textSize="20dp"
android:textAllCaps="false"
android:layout_marginTop="100dp"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="按钮3"
android:textSize="20dp"
android:textAllCaps="false"
android:layout_marginTop="300dp"/>
</LinearLayout>
</ScrollView>
运行程序,现在就可以向下滚动,看到按钮3了:
————————————————
版权声明:本文为CSDN博主「冷暖自知_源」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_36243942/article/details/82185051
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!