要实现如图的布局:

这是在eclipse可视化窗口中的截图,但实际运行在Android设备上可能出现的问题有:

(1):当编辑图1中的最后一个EditText时,输入法的编辑界面会把底部的Button顶上去,遮挡住了最后一个EditText;

(2):图2中的控件太多,以至于无法一屏全部显示,导致底部的Button被挤下去,又无法滚动控件,导致无法操作Button;

解决方案:

以下为布局文件代码:

图  1:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" > <ScrollView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="@+id/linearLayout1"
android:fillViewport="true" > <TableLayout
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1" > <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/product_name" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/product_name" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/product_id" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/product_id" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/raise_company" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/raise_company" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="@string/about_info" /> <EditText
android:layout_height="wrap_content"
android:layout_weight="2"
android:hint="@string/about_quality_website" >
</EditText>
</TableRow>
</TableLayout>
</ScrollView> <LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:paddingBottom="0dp" > <Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/edit" /> <Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/refer" >
</Button>
</LinearLayout> </RelativeLayout>

图  2:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/view"
android:layout_width="fill_parent"
android:layout_height="fill_parent" > <RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" > <ScrollView
android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" > <TableLayout
android:id="@+id/table"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1" > <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/product_name" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/product_name" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/product_id" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/product_id" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/current_data" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/current_data" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/raise_company" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/raise_company" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/raise_man" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/raise_man" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/feed_name" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/feed_name" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/feed_element" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/feed_element" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/medicine" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/medicine" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/health_condition" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/health_condition" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/water_quality" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/water_quality" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/water_temperature" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/water_temperature" >
</EditText>
</TableRow> <TableRow> <TextView
android:layout_width="60dp"
android:layout_height="wrap_content"
android:text="@string/record" /> <EditText
android:layout_height="wrap_content"
android:hint="@string/record" >
</EditText>
</TableRow>
</TableLayout>
</ScrollView> <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/view1" > <Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/edit" /> <Button
android:layout_width="70dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:text="@string/refer" >
</Button>
</LinearLayout>
</RelativeLayout> </ScrollView>

需要说明的是:图一结构为:

图二结构为:

图二没有遮挡的问题,所以没有去修改它

结束语:关于Android中布局文件的滚动和控件遮挡问题已经描述和解决,作为一篇记录学习过程的文章,也希望能够帮助别人一起学习。

附上的代码,如果你喜欢,欢迎拿去,顺便,如果你把它完善的根据完美漂亮,也希望你反馈到这里  ^_^

Android 布局 中实现适应屏幕大小及组件滚动的更多相关文章

  1. 在Eclipse Android中设置模拟器屏幕大小

    在Eclipse Android中设置模拟器屏幕大小是本文要介绍的内容,主要是来了解并学习Eclipse Android中模拟器的设置,具体关于Eclipse Android内容的详解来看本文. 方法 ...

  2. Android布局中的空格以及占一个汉字宽度的空格的实现

    在Android布局中进行使用到空格,以便实现文字的对齐.那么在Android中如何表示一个空格呢? 空格:  窄空格:  一个汉字宽度的空格:   [用两个空格(  )占一个汉字的宽度时,两个空格比 ...

  3. Android布局中的空格以及占一个汉字宽度的空格,实现不同汉字字数对齐

    前言 在Android布局中进行使用到空格,以便实现文字的对齐.那么在Android中如何表示一个空格呢? 空格: (普通的英文半角空格但不换行) 窄空格:   (中文全角空格 (一个中文宽度))   ...

  4. android布局中使用include及需注意点

    在android布局中,使用include,将另一个xml文件引入,可作为布局的一部分,但在使用include时,需注意以下问题: 一.使用include引入 如现有标题栏布局block_header ...

  5. Android布局中的layout_weight和weightSum属性的详解及使用

    由于Android设备的尺寸大小不一,种类繁多,当我们在开发应用的时候就要考虑屏幕的适配型了,尽可能让我们的应用适用于主流机型的尺寸,这样我们的应用不会因为尺寸不同而不美观,解决屏幕适配问题的方法有很 ...

  6. Android针对不同的手机屏幕大小设计图片资源与编码

    注:本文转载于:http://blog.csdn.net/welovesunflower/article/details/7930248 一些术语 Screen Size 屏幕尺寸: 实际的物理尺寸, ...

  7. 【转】在Android布局中使用include和merge标签

    内容转自:http://fengweipeng1208.blog.163.com/blog/static/21277318020138229754135/ 在我们开发android布局时,经常会有很多 ...

  8. Android布局中涉及的一些属性

    Android:gravity属性 线性布局常见的就是利用LinearLayout进行布局,其中有个比较重要的属性就是android:gravity,在官方文档中是这么描述这个属性的:指定一个元素怎么 ...

  9. android 布局中 layout_gravity、gravity、orientation、layout_weight

    线性布局中,有 4 个及其重要的参数,直接决定元素的布局和位置,这四个参数是 android:layout_gravity ( 是本元素相对于父元素的重力方向 ) android:gravity (是 ...

随机推荐

  1. C++中创建对象的时候加括号和不加括号的区别

    c++创建对象的语法有----- 1 在栈上创建 MyClass a; 2 在堆上创建加括号 MyClass *a= new MyClass(); 3 不加括号 MyClass *a = new My ...

  2. asp.net常用函数

    ASP.NET网络编程中常用到的27个函数集 Abs(number) 取得数值的绝对值.   Asc(String) 取得字符串表达式的第一个字符ASCII 码.   Atn(number) 取得一个 ...

  3. Hive中数据的加载和导出

    原文:http://blog.javachen.com/2014/06/09/hive-data-manipulation-language.html 关于 Hive DML 语法,你可以参考 apa ...

  4. java_Oralce

    简单范例 create or replace procedure delete_table is i number(10); begin for x in (select * from emp whe ...

  5. 《Entity Framework 6 Recipes》中文翻译——第十章EntityFramework存储过程处理(八)

    将插入.更新和删除操作映射到存储过程 问题 您想在存储过程中映射插入.更新和删除操作. 解决方案 下图所示的运动员Athlete实体模型.底层数据库有一张运动员Athlete表.您想使用存储过程进行实 ...

  6. 给jdk写注释系列之jdk1.6容器(5)-LinkedHashMap源码解析

    前面分析了HashMap的实现,我们知道其底层数据存储是一个hash表(数组+单向链表).接下来我们看一下另一个LinkedHashMap,它是HashMap的一个子类,他在HashMap的基础上维持 ...

  7. Adobe Edge Animate –弹性的方块-使用tweenmax缓动效果

    Adobe Edge Animate –弹性的方块-使用tweenmax缓动效果 版权声明: 本文版权属于 北京联友天下科技发展有限公司. 转载的时候请注明版权和原文地址. 此前有Edge爱好者提出一 ...

  8. LeetCode 42

    Trapping Rain Water Given n non-negative integers representing an elevation map where the width of e ...

  9. [未完成]WebService学习第一天学习笔记

    [未完成]WebService学习第一天学习笔记[未完成]WebService学习第一天学习笔记

  10. Delphi各个版本和发展历史(转)

    Delphi,是Windows平台下著名的快速应用程序开发工具(Rapid Application Development,简称RAD).它的前身,即是DOS时代盛行一时的“BorlandTurbo ...