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. 5.27 indeed 第三次网测

    1. 第一题, 没有看 2. 暴力枚举.每一个部分全排列, 然后求出最大的请求数. #include<bits/stdc++.h> #define pb push_back typedef ...

  2. 如何正确从windows系统(自己电脑)远程访问Linux系统(他人电脑)的mysql数据库(图文详解)

    这里,需要Linux系统开了root用户,我这给root用户密码为root.     同时,在mysql -uroot -proot执行进去之后 update user setHost='%' whe ...

  3. SQL Server跨库跨服务器访问实现

    我们经常会遇到一个数据库要访问另一个数据库,或者一台服务器要访问另一台服务器里面的数据库. 那么这个如何实现的呢? 相信看完这篇文章你就懂了! 同一台服务器跨库访问实现 1. 首先创建两个数据库Cro ...

  4. javascript 核心概念(1)-数据类型

    语法 (1)到现在为止,大多数浏览器也还是支持到ECMAScript 第三版的标准. 核心概念就是一个语言的基本工作原理,涉及语法,操作符,数据类型. (2)javascript的一切--变量,函数名 ...

  5. MySQL定期执行任务相关问题

    在sqlyog某数据库下的事件里新建事件,并写入一下代码: DELIMITER $$ ALTER DEFINER=`root`@`%` EVENT `0` ON SCHEDULE EVERY 24 H ...

  6. Java中final、finally、finalize的区别与用法

    1.简单区别:final用于声明属性,方法和类,分别表示属性不可交变,方法不可覆盖,类不可继承.finally是异常处理语句结构的一部分,表示总是执行.finalize是Object类的一个方法,在垃 ...

  7. Android截图截取弹框AlertDialog

    1:效果如图 2:权限 <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="21" ...

  8. Windows7 win10 系统如何强制禁用驱动程序签名

    转载自奇兔 Win7 64位系统禁用驱动程序签名强制    Win7系统是比较稳定的一款系统,也是最多人在使用的一款系统.当我们在Win7系统中安装驱动程序的时候,对安装的驱动程序需要数字签名,否则驱 ...

  9. Embedded之Stack之一

    1 Intro When a program starts executing, a certain contiguous section of memory is set aside for the ...

  10. dubbo之泛化实现

    实现泛化调用 泛化接口调用方式主要用于客户端没有 API 接口及模型类元的情况,参数及返回值中的所有 POJO 均用 Map 表示,通常用于框架集成,比如:实现一个通用的服务测试框架,可通过 Gene ...