安卓开发中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 ...
随机推荐
- rdesktop命令连接Win7远程桌面
1. 开启远程服务,并添加远程桌面用户: 2. 远程桌面开启失败,如果远程桌面开启失败,到服务控制台里面去找到“remote desktop services”依赖的几个服务,是不是被禁用了.都开启一 ...
- Java集合的实现细节—Set集合和Map集合
Set:代表无序.不可重复的集合 Map:代表key-value对集合,也称为关联数组 从表面上看,Set和Map相似性很少,但实际上可以说Map集合时Set集合的扩展. 1.Set集合和Map集合的 ...
- 基于PCA的特征提取
图像处理方面的知识也学了一段时间了,总是光看理论的话,感觉联系不上实际,第一次把理论综合的实现出来,对这些理论的印象才感觉的更深刻,也能够为后续的学习打下良好的基础. PCA是比较老的算法,但是可靠性 ...
- hdu 4869 Turn the pokers(组合数+费马小定理)
Problem Description During summer vacation,Alice stay at home for a long time, with nothing to do. S ...
- CGI、FastCGI和php-fpm的区别
参考网上的描述,将网上的描述内容,整理进来: 首先,CGI是干嘛的?CGI是为了保证web server传递过来的数据是标准格式的,方便CGI程序的编写者.web server(比如说nginx)只是 ...
- HDU--4784 Dinner Coming Soon DP+BFS
题意非常长非常变态.一个人要到他男朋友家,他最初有R元以及T分钟的时间来赶到他男朋友家.有N个房子M条道路,每条道路有须要消耗的时间以及过路费,同一时候还要顺路做食盐生意,起初身上没有食盐,最多带B袋 ...
- qwtplot3D安装及运行-----终结解决方案
..\qwtplot3d\include\qwt3d_openglhelper.h:67: 错误:'gluErrorString' was not declared in this scope..\q ...
- ORA-24324、ORA-12560、ORA-12514
SQL> startup ERROR: ORA-24324: 未初始化服务句柄 ORA-01041: 内部错误, hostdef 扩展名不存在. SQL> conn sys /nolog; ...
- Linux的目录结构及其作用
/bin bin是Binary的缩写.这个目录存放着最经常使用的命令. /boot这里存放的是启动Linux时使用的一些核心文件,包括一些连接文件以及镜像文件. /dev dev是Device(设备) ...
- asp.net获取ip地址的方法
在ASP中使用 Request.ServerVariables("REMOTE_ADDR") 来取得客户端的IP地址,但如果客户端是使用代理服务器来访问,那取到的就是代理服务器的I ...