• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
火磷
Memory will fade,but not notes.
博客园    首页    新随笔    联系   管理    订阅  订阅
Android开发--ScrollView的应用

1.简介

当内容无法全部显示时,需要采取滚动的方式获取其与内容。其中,ScrollView为垂直滚动控件,HorizontalScrollView为水平滚动控件。

2.构建

     

XML代码:

 1 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 2     xmlns:tools="http://schemas.android.com/tools"
 3     android:layout_width="match_parent"
 4     android:layout_height="match_parent"
 5     android:paddingBottom="@dimen/activity_vertical_margin"
 6     android:paddingLeft="@dimen/activity_horizontal_margin"
 7     android:paddingRight="@dimen/activity_horizontal_margin"
 8     android:paddingTop="@dimen/activity_vertical_margin"
 9     tools:context="example.scrollview.Activity1" >
10 
11     <TextView
12         android:id="@+id/textView1"
13         android:layout_width="fill_parent"
14         android:layout_height="wrap_content"
15         android:layout_alignParentTop="true"
16         android:gravity="center"
17         android:text="@string/tv1" />
18 
19     <ScrollView
20         android:id="@+id/scrollView1"
21         android:layout_width="wrap_content"
22         android:layout_height="wrap_content"
23         android:layout_alignParentStart="true"
24         android:layout_below="@+id/textView1"
25         android:layout_marginTop="20dp" >
26 
27         <LinearLayout
28             android:layout_width="match_parent"
29             android:layout_height="wrap_content"
30             android:orientation="vertical" >
31 
32             <TextView
33                 android:id="@+id/textView2"
34                 android:layout_width="match_parent"
35                 android:layout_height="538dp"
36                 android:text="@string/tv2" />
37 
38         </LinearLayout>
39     </ScrollView>
40 </RelativeLayout>
41 
42  

 

posted on 2016-02-03 16:11  火磷  阅读(441)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3