安卓开发中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 ...
随机推荐
- apache 启动不了
netstat -ano|findstr "443" 发现443端口被占 记录下443端口对应的PID 进入任务管理器,查看进程,发现为一个叫做vmware-hostd.exe的进 ...
- 什么时候该使用NoSQL存储数据库?
原文地址:http://www.jdon.com/39240 文章总结以下几点:1.频繁写,很少读统计数据,比如点击率,应该使用基于内存的in-memory的key/value存储数据库如Redis, ...
- 修改xcode代码风格设置
1.找到文件:/Applications/Xcode.app/Contents/PlugIns/IDECodeSnippetLibrary.ideplugin/Contents/Resources/S ...
- 一个跨域请求的XSS续
之前讨论过,在解决post跨域请求时,采用iframe+本域代理页的形式,兼容性(当然是包括IE6啦)是最好的.上次提到,代理页面的作用是:执行本域下的回调函数.就是这个原因,给XSS带来了便利.详细 ...
- 关于bootstrap--表单(下拉<select>、输入框<input>、文本域<textare>复选框<checkbox>和单选按钮<radio>)
html 里面的 role 本质上是增强语义性,当现有的HTML标签不能充分表达语义性的时候,就可以借助role来说明.通常这种情况出现在一些自定义的组件上,这样可增强组件的可访问性.可用性和可交互性 ...
- JAVA并发实现二(线程中止)
package com.subject01; public class InterruptDemo { public static void main(String[] args) { SimpleT ...
- poj 2407 Relatives(简单欧拉函数)
Description Given n, a positive integer, how many positive integers less than n are relatively prime ...
- Query语句对系统性能的影响
需求: 取出某个group(假设id为1)下的用户编号id,用户昵称(nick_name),并按照加入组的时间(user_group.gmt_create)来进行倒序排列,取出前20个 解决方案一: ...
- 关于sys、system、sysman等在EM中登录的问题
1.sysman要先在SQL*Plus上解锁: (1)以"sysdba"的身份登录 conn system/密码 as sysdba; (2)解锁 alter user sysma ...
- jquery商城类封装插件
自从解决了定时器的问题后,什么都好弄了 这是仿苏宁商城banner的,当然我没弄得那么好啦,但是我想就是那个缩略图,我没弄好吧,方法我猜想是通过把所有li都放进数组,然后通过遍历,就可以做出相应的效果 ...