RelativeLayout的意义:

布局各个部件的相对布局。使得界面空间合理利用。

一、ScrollView局限:

滑动的只能是linearlayout,甚至整个布局都不能有RelativeLayout。这使得让人觉得ScrollView控件有点鸡肋。其实不然..........

linearlayout跟RelativeLayout布局在界面上来看只是空间间隔的区别,而在liearlayout中有一个<View/>能占用空间,单单用linearlayout要达到    RelativeLayout的效果,可以用<View/>来实现。

二、View用法

<View

android:layout_width="fill_parent"

android:layout_height="10sp"

/>

三、例子

下面的界面

1)用RelativeLayout实现非常容易实现

RelativeLayout代码

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
tools:context=".ClientActivity" >
<ImageView
android:id="@+id/clientinfo_headpicture"
android:layout_width="90sp"
android:layout_height="90sp"
android:background="@drawable/client_pic_back"
android:src="@drawable/client_pic_src" />
<TextView
android:id="@+id/client_tel"
android:layout_width="match_parent"
android:layout_height="30sp"
android:layout_alignBottom="@+id/clientinfo_headpicture"
android:layout_toRightOf="@+id/clientinfo_heaspicture"
android:background="@color/black"
android:ems=""
android:singleLine="true"
android:text="电话号码"
android:textColor="@color/white" />
<Button
android:id="@+id/client_tel_edit"
android:layout_width="50sp"
android:layout_height="30sp"
android:layout_above="@+id/client_tel"
android:layout_alignParentRight="true"
android:background="@drawable/cliebt_button_edittel"
android:text="编辑"
android:textColor="@color/blue" />
<TextView
android:layout_width="match_parent"
android:layout_height="30sp"
android:layout_alignLeft="@+id/client_tel"
android:layout_alignParentTop="true"
android:background="@color/black"
android:singleLine="true"
android:text="用户名"
android:textColor="@color/white"
android:textSize="24sp" />
<View
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="10sp"
android:layout_alignParentRight="true"
android:layout_below="@+id/clientinfo_headpicture"
android:background="@color/blue" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/view1"
android:background="@drawable/client_moreinfo_back" >
<Button
android:id="@+id/client_myaddress"
android:layout_width="50sp"
android:layout_height="30sp"
android:background="@drawable/client_address" />
<TextView
android:id="@+id/client_myaddress_text"
android:layout_width="wrap_content"
android:layout_height="30sp"
android:layout_alignBaseline="@+id/client_myaddress"
android:layout_alignBottom="@+id/client_myaddress"
android:layout_toRightOf="@+id/client_myaddress"
android:text="我的地址"
android:textColor="@color/blue"
android:textSize="24sp" />
<View
android:id="@+id/client_myaddress_div"
android:layout_width="fill_parent"
android:layout_height="1sp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/client_myaddress"
android:background="@color/blue" />
<TextView
android:id="@+id/client_myaddress_addtext"
android:layout_width="160sp"
android:layout_height="50sp"
android:layout_alignLeft="@+id/client_myaddress_div"
android:layout_below="@+id/client_myaddress_div"
android:layout_marginLeft="14sp"
android:text="31栋127寝室电话18607060000"
android:textColor="@color/blue" />
<Button
android:id="@+id/client_myaddress_edit"
android:layout_width="40sp"
android:layout_height="40sp"
android:layout_alignRight="@+id/client_myaddress_div"
android:layout_alignTop="@+id/client_myaddress_addtext"
android:background="@drawable/client_edit" />
<View
android:id="@+id/client_buyhistory_div"
android:layout_width="fill_parent"
android:layout_height="5sp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/client_myaddress_addtext"
android:background="@color/blue" />
<Button
android:id="@+id/client_buyhistory"
android:layout_width="50sp"
android:layout_height="30sp"
android:layout_below="@+id/client_buyhistory_div"
android:layout_marginTop="1sp"
android:layout_toLeftOf="@+id/client_myaddress_text"
android:background="@drawable/client_shopcar" />
<TextView
android:id="@+id/client_buyhistory_text"
android:layout_width="100sp"
android:layout_height="30sp"
android:layout_alignRight="@+id/client_myaddress_text"
android:layout_alignTop="@+id/client_buyhistory"
android:text="已购买"
android:textColor="@color/blue"
android:textSize="24sp" />
<View
android:id="@+id/client_buyhistory_div_div"
android:layout_width="fill_parent"
android:layout_height="1sp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/client_buyhistory"
android:background="@color/blue" />
<TextView
android:id="@+id/client_buyhistory_info"
android:layout_width="160sp"
android:layout_height="30sp"
android:layout_alignLeft="@+id/client_buyhistory_div_div"
android:layout_below="@+id/client_buyhistory_div_div"
android:text="北京烤鸭100元"
android:textColor="@color/blue" />
<Button
android:id="@+id/client_buyhistory_eidt"
android:layout_width="40sp"
android:layout_height="40sp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="@drawable/client_edit" />
<View
android:id="@+id/client_store_div"
android:layout_width="fill_parent"
android:layout_height="5sp"
android:layout_alignParentRight="true"
android:layout_below="@+id/client_buyhistory_eidt"
android:background="@color/blue" />
<Button
android:id="@+id/client_store"
android:layout_width="50sp"
android:layout_height="30sp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/client_store_div"
android:background="@drawable/client_stored" />
<TextView
android:id="@+id/client_store_text"
android:layout_width="80sp"
android:layout_height="30sp"
android:layout_alignBaseline="@+id/client_store"
android:layout_alignBottom="@+id/client_store"
android:layout_alignLeft="@+id/client_myaddress_text"
android:text="收藏"
android:textColor="@color/blue"
android:textSize="24sp" />
<View
android:id="@+id/client_store_div_div"
android:layout_width="fill_parent"
android:layout_height="1sp"
android:layout_alignParentLeft="true"
android:layout_below="@+id/client_store"
android:background="@color/blue" />
<Button
android:id="@+id/client_store_edit"
android:layout_width="40sp"
android:layout_height="40sp"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/client_store_info"
android:background="@drawable/client_edit" />
<View
android:id="@+id/View01"
android:layout_width="fill_parent"
android:layout_height="5sp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="@color/blue" />
<TextView
android:id="@+id/client_store_info"
android:layout_width="160sp"
android:layout_height="40sp"
android:layout_alignLeft="@+id/View01"
android:layout_below="@+id/client_store_div_div"
android:text="北京烤鸭30元"
android:textColor="@color/blue" />
</RelativeLayout>
</RelativeLayout>

但因为有个项目用到的是TabHost,对子activity的布局有限制,上面的布局超过范围。所以要用到ScrollView,为达到上面的布局,要用到<View/>控件。

安卓开发中ScrollView不能用RelativeLayout的解决方案的更多相关文章

  1. 【Android】安卓开发中的布局与事件

    [Android]安卓开发中的布局与事件 1.Android Studio下载配置 非常简单的百度然后点击下载安装就好了.注意的是,本来我是打算使用评价还不错的Genymotion这个软件来充当虚拟机 ...

  2. Android安卓开发中图片缩放讲解

    安卓开发中应用到图片的处理时候,我们通常会怎么缩放操作呢,来看下面的两种做法: 方法1:按固定比例进行缩放 在开发一些软件,如新闻客户端,很多时候要显示图片的缩略图,由于手机屏幕限制,一般情况下,我们 ...

  3. 安卓开发中使用Genymotion模拟器

    在安卓开发中,运行和调试自己所写的安卓程序需要用到模拟器 在一般情况下 是直接在这创建一个模拟器,但是这种自带的模拟器运行效率不佳,而且启动时间漫长 所以,我们可以换一款安卓模拟器 Genymotio ...

  4. iOS开发中遇到的一些问题及解决方案【转载】

    iOS开发中遇到的一些问题及解决方案[转载] 2015-12-29 [385][scrollView不接受点击事件,是因为事件传递失败] // //  MyScrollView.m //  Creat ...

  5. 关于软件开发中兼容win7注册表的解决方案

    关于软件开发中兼容win7注册表的解决方案   编写人:CC阿爸 2014-3-14 l  近来在开发一winform程序时,发现在xp 系统访问注册表一切正常.可偏这个时候,微软又提醒大家.Xp今年 ...

  6. 安卓开发中Spinner控件的使用

    在安卓手机应用开发中,Spinner对象常用方法有以下五种. 用法 1 :以资源方式,静态展示 Spinner 选项 用法 2 :以代码方式,动态展示 Spinner 选项 用法 3 :同时显示图片和 ...

  7. 非常不错的android应用开发详解在安卓开发中

    我们在苹果开发中,总会看到XCode,Interface Builder,Object-c这如此入耳入随的单词,但往往多数人在认为XCODE看着简单,InterfaceBuilder好似操作, 而Ob ...

  8. 安卓开发中strings.xml的使用

    为了使用方便也是为了代码规范化,我们都将文字信息放在res-values-strings.xml中, 因为开发中需要用到将文字的换行,百度了一下,可以将文字段信息直接在strings.xml文件中换行 ...

  9. 在安卓开发中使用SQLite数据库操作实例

    前段时间写了个安卓平台下SQLite数据库操作的实例 ,一直没得时间总结 ,今天把它弄出来了. 在Android 运行时环境包含了完整的 SQLite. 首先介绍一下SQLite这个数据库: SQLi ...

随机推荐

  1. SSH转发机制

    第一部分 概述 当你在咖啡馆享受免费 WiFi 的时候,有没有想到可能有人正在窃取你的密码及隐私信息?当你发现实验室的防火墙阻止了你的网络应用端口,是不是有苦难言?来看看 SSH 的端口转发功能能给我 ...

  2. BZOJ1430: 小猴打架

    1430: 小猴打架 Time Limit: 5 Sec  Memory Limit: 162 MBSubmit: 328  Solved: 234[Submit][Status] Descripti ...

  3. 2015第24周三Spring事务3

    在一个典型的事务处理场景中,有以下几个参与者: Resource Manager(RM) ResourceManager简称RM,它负责存储并管理系统数据资源的状态,比如数据库服务器,JMS消息服务器 ...

  4. NOI2011 NOI嘉年华

    http://www.lydsy.com/JudgeOnline/problem.php?id=2436 首先离散化,离散化后时间范围为[1,cnt]. 求出H[i][j],表示时间范围在[i,j]的 ...

  5. 浅谈C++中指针和引用的区别者之间的区别和用法(转)

    指针和引用在C++中很常用,但是对于它们之间的区别很多初学者都不是太熟悉,下面来谈谈他们2者之间的区别和用法. 1.指针和引用的定义和性质区别: (1)指针:指针是一个变量,只不过这个变量存储的是一个 ...

  6. Zedboard甲诊opencv图像处理(三)

    整个工程进展到这一步也算是不容易吧,但技术含量也不怎么高,中间乱起八糟的错误太烦人了,不管怎么样,现在面临了最大的困难吧,图像处理算法.算法确实不好弄啊,虽然以前整过,但都不是针对图像的. 现在的图像 ...

  7. nyoj201 作业题

    作业题 时间限制: 3000 ms  |  内存限制: 65535 KB 难度: 3   描述 小白同学这学期有一门课程叫做<数值计算方法>,这是一门有效使用数字计算机求数学问题近似解的方 ...

  8. Unity发送短信

    闲来无事,觉得用uinity来发送短信挺有意思的,所以自己差了点资料,看看能否实现,结果还真的可以!废话不多说,直接码! 1,新建一空工程,我们就简单的使用UGUI搭建一个丑陋的界面吧! 2,界面极其 ...

  9. 17 java 存在的问题(转)

    java的问题: 1.性能:java的内存管理似乎比较自动化,但其实性能不是特别好.尤其是new对象的时候没有节制.在java中,有些对象构造成本很低,有些 很高.特别在UI编程的时候,大多数的UI对 ...

  10. poj3264 线段树

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 44121   Accepted: 20715 ...