android基础:android页面添加滚动条

这篇博客介绍了在Android应用中创建滚动效果的方法。首先,创建一个Android项目,然后在activity_main.xml布局文件中删除原有内容,插入ScrollView作为容器,并在其中添加多个TextView和一个Button。每个TextView显示相同的文本,用于演示滚动效果。运行项目,即可看到带有滚动条的页面。关键在于使用<ScrollView>标签来实现下拉滚动,注意其内部只能放置一个父视图。
摘要由CSDN通过智能技术生成

1、建立一个android项目。

2、打开layout下的activity_main.xml文件,如果创建项目事修改了activity_main.xml文件就选择你修改的文件名。

3、删除activity_main.xml文件中内容。

4、将下列文件布置到activity_main.xml中。

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

<RelativeLayout
    android:layout_width="fill_parent"   
    android:layout_height="wrap_content"
    <!-- 需要上传一张图片 也可以去掉这行--> android:background="@drawable/back"
  >

    
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="22dp"
        android:layout_marginTop="17dp"
        android:text="@string/hello_world" />

    <TextView
        android:id="@+id/TextView01"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignLeft="@&#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值