安卓开发中ScrollView不能用RelativeLayout的解决方案
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的解决方案的更多相关文章
- 【Android】安卓开发中的布局与事件
[Android]安卓开发中的布局与事件 1.Android Studio下载配置 非常简单的百度然后点击下载安装就好了.注意的是,本来我是打算使用评价还不错的Genymotion这个软件来充当虚拟机 ...
- Android安卓开发中图片缩放讲解
安卓开发中应用到图片的处理时候,我们通常会怎么缩放操作呢,来看下面的两种做法: 方法1:按固定比例进行缩放 在开发一些软件,如新闻客户端,很多时候要显示图片的缩略图,由于手机屏幕限制,一般情况下,我们 ...
- 安卓开发中使用Genymotion模拟器
在安卓开发中,运行和调试自己所写的安卓程序需要用到模拟器 在一般情况下 是直接在这创建一个模拟器,但是这种自带的模拟器运行效率不佳,而且启动时间漫长 所以,我们可以换一款安卓模拟器 Genymotio ...
- iOS开发中遇到的一些问题及解决方案【转载】
iOS开发中遇到的一些问题及解决方案[转载] 2015-12-29 [385][scrollView不接受点击事件,是因为事件传递失败] // // MyScrollView.m // Creat ...
- 关于软件开发中兼容win7注册表的解决方案
关于软件开发中兼容win7注册表的解决方案 编写人:CC阿爸 2014-3-14 l 近来在开发一winform程序时,发现在xp 系统访问注册表一切正常.可偏这个时候,微软又提醒大家.Xp今年 ...
- 安卓开发中Spinner控件的使用
在安卓手机应用开发中,Spinner对象常用方法有以下五种. 用法 1 :以资源方式,静态展示 Spinner 选项 用法 2 :以代码方式,动态展示 Spinner 选项 用法 3 :同时显示图片和 ...
- 非常不错的android应用开发详解在安卓开发中
我们在苹果开发中,总会看到XCode,Interface Builder,Object-c这如此入耳入随的单词,但往往多数人在认为XCODE看着简单,InterfaceBuilder好似操作, 而Ob ...
- 安卓开发中strings.xml的使用
为了使用方便也是为了代码规范化,我们都将文字信息放在res-values-strings.xml中, 因为开发中需要用到将文字的换行,百度了一下,可以将文字段信息直接在strings.xml文件中换行 ...
- 在安卓开发中使用SQLite数据库操作实例
前段时间写了个安卓平台下SQLite数据库操作的实例 ,一直没得时间总结 ,今天把它弄出来了. 在Android 运行时环境包含了完整的 SQLite. 首先介绍一下SQLite这个数据库: SQLi ...
随机推荐
- http://wiki.apache.org/tomcat/HowTo
http://wiki.apache.org/tomcat/HowTo Contents Meta How do I add a question to this page? How do I con ...
- VS项目如何添加到svn
SVN是Subversion的简称,是一个开放源代码的版本控制系统,相较于RCS.CVS,它采用了分支管理系统,它的设计目标就是取代CVS.这里就讲一下VS2010如何将项目导入SVN版本控制. 工具 ...
- linux自动交互工具expect,tcl安装和安装包,以及自动互信脚本
linux自动交互工具expect,tcl安装,以及自动互信脚本 工作中需要对几十台服务器做自动互信,无意中发现expect命令,研究一番. 在网上找了许多资料也没有安装成功,摸索着总算成功了.现分享 ...
- HDU 4907 Task schedule
对于询问q 假设q不存在直接输出q 否则输出后面第一个不存在的数 从2*10^5到1遍历一边ac #include<bits/stdc++.h> using namespace std; ...
- Sonar入门(四):Eclipse集成Sonar
sonar及其插件在项目中的使用方法 Sonar平台 Sonar平台的安装见一文, 在Sonar平台上进行的检查可以通过hudson进行触发, A. 没有做持续集成的项目可以复制以下hudson上的任 ...
- BGP
http://network.51cto.com/art/200912/172439.htm http://blog.sina.com.cn/s/blog_b457dde80101cyqr.html ...
- Hacker(19)----检测Windows系统漏洞
想完全掌握Windows中存在的漏洞需要使用专业的漏洞扫描软件.目前常用的有MBSA(MircosoftBaselineSecurityAnalyzer).360安全卫士等. 一.使用MBSA检测系统 ...
- 普通用户之间的ssh无密码访问设置方法
两台CentOS6.2服务器,客户端是node1,服务器是node2,先都用root用户配置,方法如下: 第一步:在客户端Node1:生成密匙对,我用的是rsa的密钥.使用命令 "ssh-k ...
- asp Eval()函数的一些使用总结
一.函数的原型: Eval(string s); s可以是变量,表达式,语句: 二.使用: 1.s为变量时,返回该变量的值,如:string s = "sss";Eval(s);/ ...
- 在html页头设置不缓存
方法一:在<head>标签里增加如下meta标签. <meta http-equiv="Content-Type" content="text/html ...