1.父控件中含有多个子控件时。往往遵循长子优先的原则,即长子假设非常大可能占满父空间。使次子们出局;

2.如果TableLayout有2行,当中一行未设定列间长度比例。而还有一行设定了,则未设定行可能也会遵循设定行的列间长度比例;

3.ImageView中的scaleType,对android:src="@drawable/logo"。而对android:background="@drawable/logo"可能不起作用;

4.在某个区域(如TableLayout中某个单元格)显示某张超大的图片。希望图片总是自适应单元格而不是把单元格撑爆。解决方式:将单元格放在LinearLayout中,给LinearLayout设置android:layout_width="wrap_content"、android:orientation="horizontal"。给单元格设置layout_weight属性、不设置android:layout_width属性。

<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="match_parent"
android:background="#ffffff"> <TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/include1"
android:background="#dedcd2"
android:stretchColumns="*" > <TableRow
android:layout_margin="0.5dip"
android:background="#dedcd2" > <LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:orientation="horizontal" > <TextView
android:layout_height="fill_parent"
android:layout_margin="1dip"
android:layout_weight="2"
android:background="#ffffff"
android:text=""
android:textSize="12dp"
android:textStyle="bold" /> <TextView
android:layout_height="fill_parent"
android:layout_margin="1dip"
android:layout_weight="2"
android:background="#ffffff"
android:text=""
android:textSize="12dp"
android:textStyle="bold" /> <!-- @drawable/right 为超大图片 -->
<ImageView
android:layout_height="fill_parent"
android:layout_margin="1dip"
android:layout_weight="1"
android:src="@drawable/right" /> <TextView
android:layout_height="fill_parent"
android:layout_margin="1dip"
android:layout_weight="2"
android:background="#ffffff"
android:text=""
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>
</TableRow>
</TableLayout> </RelativeLayout> 1.父控件中含有多个子控件时。往往遵循长子优先的原则,即长子如果非常大可能占满父空间,使次子们出局; 2.如果TableLayout有2行,当中一行未设定列间长度比例,而还有一行设定了,则未设定行可能也会遵循设定行的列间长度比例; 3.ImageView中的scaleType,对android:src="@drawable/logo",而android:background="@drawable/logo",我就笨笨地犯了这个低级错误,导致错怪人家scaleType不起作用。 3.在某个区域(如TableLayout中某个单元格)显示某张超大的图片,希望图片总是自适应单元格而不是把单元格撑爆。 解决方式:将单元格放在LinearLayout中,给LinearLayout设置android:layout_width="wrap_content"、android:orientation="horizontal"。给单元格设置layout_weight属性、不设置android:layout_width属性。 <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="match_parent"
android:background="#ffffff"> <TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/include1"
android:background="#dedcd2"
android:stretchColumns="*" > <TableRow
android:layout_margin="0.5dip"
android:background="#dedcd2" > <LinearLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:orientation="horizontal" > <TextView
android:layout_height="fill_parent"
android:layout_margin="1dip"
android:layout_weight="2"
android:background="#ffffff"
android:text=""
android:textSize="12dp"
android:textStyle="bold" /> <TextView
android:layout_height="fill_parent"
android:layout_margin="1dip"
android:layout_weight="2"
android:background="#ffffff"
android:text=""
android:textSize="12dp"
android:textStyle="bold" /> <!-- @drawable/right 为超大图片 -->
<ImageView
android:layout_height="fill_parent"
android:layout_margin="1dip"
android:layout_weight="1"
android:src="@drawable/right" /> <TextView
android:layout_height="fill_parent"
android:layout_margin="1dip"
android:layout_weight="2"
android:background="#ffffff"
android:text=""
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>
</TableRow>
</TableLayout> </RelativeLayout>

Android布局文件经验的更多相关文章

  1. Xamarin Android布局文件没有智能提示

    Xamarin Android布局文件没有智能提示 在Visual Studio 2015中,Android项目的Main.axml文件没有智能提示,不便于布局文件的编写.解决办法:(1)从Xamar ...

  2. Android布局文件夹引起的问题

    Android 运行到setContentView(R.layout.splash); 总是出现如下的错误: java.lang.RuntimeException: Unable to start a ...

  3. android 布局文件中xmlns:android="http://schemas.android.com/apk/res/android"

    http://blog.163.com/benben_long/blog/static/199458243201411394624170/ xmlns:android="http://sch ...

  4. android 布局文件中控件ID、name标签属性的命名包含“@”、“.”、“+”等等符号的含义

    1. 在项目的根目录有个配置文件“AndroidManifest.xml”,是用来设置Activity的属性的如 <?xml version="1.0" encoding=& ...

  5. Android布局文件的载入过程分析:Activity.setContentView()源代码分析

    大家都知道在Activity的onCreate()中调用Activity.setContent()方法能够载入布局文件以设置该Activity的显示界面.本文将从setContentView()的源代 ...

  6. Android布局文件layout.xml的一些属性值

        第一类:属性值 true或者 false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 andr ...

  7. Android布局文件-错误

    View requires API level 14 (current min is 8): <?xml version="1.0" encoding="utf-8 ...

  8. android 布局文件 ScrollView 中的 listView item 显示不全解决方案

    import android.content.Context;import android.util.AttributeSet;import android.widget.ListView; /** ...

  9. 【Android】Android布局文件的一些属性值

    第一类:属性值 true或者 false   android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 androi ...

随机推荐

  1. ACM_城市交通线(简单并查集)

    城市交通线 Time Limit: 2000/1000ms (Java/Others) Problem Description: A国有n座城市,编号为1~n,这n个城市之间没有任何交通线路,所以不同 ...

  2. 5.26 idea生成javadoc

  3. informix 通过ADO或ODBC连接提取数据时出现中文乱码的解决方法

    最近在做一个项目,是对INFORMIX数据库的数据进行大数据分析,INFORMIX数据库数据有上亿条,没有linux的Root权限和informix数据的生产权限,只能读取.客户要求结果显示在内网wi ...

  4. DeltaFish 校园物资共享平台 第六次小组会议

    DeltaFish 校园物资共享平台 第六次小组会议 记录人:娄雨禛 2018.6.3 任务进度(2018.5.28-2018.6.3) 前端 李鑫:商品详情界面设计.总体配色分析 刘鼎乾:卖家页面初 ...

  5. Linux rsync配置用于服务器之间传输大量的数据

    Linux的rsync 配置,用于服务器之间远程传大量的数据   [教程主题]:rsync [课程录制]: 创E [主要内容] [1] rsync介绍 Rsync(Remote Synchronize ...

  6. c#使用RSA进行注册码验证

    公司的一个项目快完成了,最后要加上注册验证,翻了n多资料,终于做出来了.现在把体验说一下,以后要用的时候也好找.~~ .Net自带的类库里面有个算法. 这个算法的原理是不对称加密的原理.不对称加密原理 ...

  7. AMQP及RabbitMQ

    AMQPAMQP协议是一个高级抽象层消息通信协议,RabbitMQ是AMQP协议的实现.它主要包括以下组件: 1.Server(broker): 接受客户端连接,实现AMQP消息队列和路由功能的进程. ...

  8. 关于python学习路线

    *Python进阶(目录/书籍/学习路线) 忘了从哪里转的了,没办法标记哦,实在不好意思... 目录:) 1. 简介&helloworld&开发环境配置 2.基本语法:标识符& ...

  9. 新书《计算机图形学基础(OpenGL版)》PPT已发布

    为方便有些老师提前备课,1-10章所有章节已发布到本博客中. 欢迎大家下载使用,也欢迎大家给我们的新书反馈与意见,谢谢!

  10. vue货币格式化组件、局部过滤功能以及全局过滤功能

    一.在这里介绍一个vue的时间格式化插件: moment 使用方法: .npm install moment --save. 2 定义时间格式化全局过滤器 在main.js中 导入组件 import ...