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. AE错误代码解释

    每当我们在进行AE开发,出现错误时经常会出现错误代码,但是我们并不知道它到底代表什么意思,这里的而错误编码我们可以对照着找到我们需要的时候常详细信息(问题是,经常还是会出现没有错误编码HRESULT ...

  2. Scala学习2 ———— 三种方式完成HelloWorld程序

    三种方式完成HelloWorld程序 分别采用在REPL,命令行(scala脚本)和Eclipse下运行hello world. 一.Scala REPL. 按照第一篇在windows下安装好scal ...

  3. 数据库操作通用函数,增强可重复利用性能C#,asp.net.sql2005

    using System;using System.Data;using System.Data.SqlClient; namespace com.hua..li{ /// <summary&g ...

  4. html中canvas渲染图片,并转化成base64格式保存

    最近在做一个上传头像然后保存显示的功能,因为涉及到裁剪大小和尺寸比例,所以直接上传图片再展示的话,就会出现问题,所以就想用canvas来渲染裁剪后的图片,然后转化成base64格式的图片再存储,这样取 ...

  5. php数据库分页

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

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

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

  7. 复习java的例子(第一天)

    1. 编写程序:从键盘上读入一个学生成绩, 存放在变量score中,根据score的值输出其对应的成绩等级: score>=90 等级: A 70=<score<90 等级: B 6 ...

  8. sql server数据库可疑状态解决方法

    前段时间客户数据服务器断电,开机后发现数据库状态标记为可疑,可能是断电引起的数据库日志文件损坏,修复方法如下: 只有mdf文件,重建日志: --注:example为测试用数据库,相应的Example_ ...

  9. 安卓代码迁移:ActionBarActivity: cannot be resolved to a type

    参考链接:http://stackoverflow.com/questions/18830736/actionbaractivity-cannot-be-resolved-to-a-type in e ...

  10. mysql 是如何保证在高并发的情况下autoincrement关键字修饰的列不会出现重复

    转载自 https://juejin.im/book/5bffcbc9f265da614b11b731/section/5c42cf94e51d45524861122d#heading-8 mysql ...