11 ScrollView

本文详细介绍了ScrollView的概念及使用方法,包括其定义、工作原理及其XML配置示例。ScrollView是一种用于容纳超过屏幕尺寸内容的容器,允许用户通过滚动查看完整信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一.滚动视图ScrollView:


1.说明:
由于手机屏幕高度有限,所以如果面对组件要显示多组信息的时候,
    ScrollView视图(滚动视图)可以有效的安排这些组件,浏览的时
可以自动的进行滚屏的操作。
2.定义:


java.lang.Object
   |-android.view.View
    |-android.view.ViewGroup
    |-android.widget.FrameLayout
    |-android.widget.ScrollView
3.原理:
  滚动视图的使用也各个布局管理器的操作形式类似。唯一不同的是,
所有的布局管理器中,可以包含多个组件,而滚动视图里只能有一个
组件,所以所谓的滚动视图指的就是提供一个专门的容器,这个容器里面可以
装下多余屏幕宽度的组件,而后采用拖拽的方式显示所有在ScrollView中的组件。


main.xml配置:


<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >


    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >


        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="姓名:" />


        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="" />


        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="学号::" />


        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="" />


        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="地址:" />


        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="" />


        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="电话:" />


        <EditText
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="" />


        <ImageView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/ni" />
    </LinearLayout>


</ScrollView>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值