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. bzoj1188

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1188 一道非常好的SG函数题,加深了对博弈论的理解. 以前做的SG函数的题,都是每个瓶子看成一 ...

  2. 什么是 docker?

    关于 Docker 是什么,有个著名的隐喻:集装箱.但是它却起了个“码头工人”( docker 的英文翻译)的名字.这无疑给使用者很多暗示:“快来用吧!用了 Docker ,就像世界出现了集装箱,这样 ...

  3. Entity framework - start

    http://blogs.msdn.com/b/adonet/archive/2010/07/19/absolue-beginners-guide-to-entity-framework.aspx?R ...

  4. hdu 5396 Expression(区间dp)

    Problem Description Teacher Mai has n numbers a1,a2,⋯,anand n−1 operators("+", "-&quo ...

  5. DenyHosts限制SSH登录尝试次数

    DenyHosts官方网站为:http://denyhosts.sourceforge.net 1. 安装 # tar -zxvf DenyHosts-2.6.tar.gz # cd DenyHost ...

  6. C#生成带项目编号的Word段落

    using System; using Microsoft.Office.Interop.Word; using Word = Microsoft.Office.Interop.Word; names ...

  7. java.lang.NoSuchFieldError: deferredExpression解决

       java.lang.NoSuchFieldError: deferredExpression这个问题的出现是在的lib下面有多个版本的jstl.jar包,解决办法很简单,只留下一个版本的jstl ...

  8. Building bridges_hdu_4584(排序).java

    Building bridges Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) ...

  9. 网页搜索功能 多表搜索sql

    SELECT ID, Title, FromTableFROM (SELECT ID, ArticleName AS Title, 'Article' AS FromTable        FROM ...

  10. RAID磁盘阵列原理

    磁盘阵列(Redundant Arrays of independent Disks,RAID),有“价格便宜具有冗余能力的磁盘阵列”之意.原理是利用数组方式来作磁盘组,配合数据分散排列的设计,提升数 ...