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. Git教程(3)git工作区与文件状态及简单示例

    基础 目录: working driectory  工作目录,就是我们的工作目录,其中包括未跟踪文件及暂存区和仓库目录. staging area   暂存区,不对应一个具体目录,其实只是git di ...

  2. SQL连接其它服务器操作

    Exec sp_droplinkedsrvlogin ZYB,Null --删除映射(录与链接服务器上远程登录之间的映射) Exec sp_dropserver ZYB --删除远程服务器链接 EXE ...

  3. winxp精简版没有IIS的解决办法

    首先在“开始”菜单的“运行”中输入“c:\Windows\inf\sysoc.inf”,系统会自动使用记事本打开sysoc.inf这个文件.在sysoc.inf中找到“[Components]”这一段 ...

  4. 努比亚(nubia) M2青春版 NX573J 解锁BootLoader 并进入临时recovery ROOT

    努比亚(nubia) M2青春版 NX573J 解锁BootLoader 并进入临时recovery ROOT 工具下载链接:https://pan.baidu.com/s/1NfRTdXtdAZRi ...

  5. 【Oracle】恢复重做日志组

    我们在Oracle的日常运维中,有可能会遇到重做日志组丢失的情况.下面我将模拟丢失不同状态的日志组,并分别给出解决办法: 重做日志有以下几种状态,如下: -  CURRENT:此状态表示正在被 LGW ...

  6. 乐乎共享wifi充电宝项目

  7. servlet_获取初始化参数

    在web.xml的<servlet>标签中增添 <init-param> <param-name>XXX</param-name> <param- ...

  8. POJ_2411_Mondriaan's Dream_状态压缩dp

    Mondriaan's Dream Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 15407   Accepted: 888 ...

  9. sql 查询替换字符

    Select  A,B,C  from  Tb1 –查询所有 Select  A,replace(B,’1’,’壹’),C  from   Tb1  替换查询 Tb1 A B C AA1 1 CC A ...

  10. python 字符串模糊匹配 Fuzzywuzzy

    Python提供fuzzywuzzy模块,不仅可用于计算两个字符串之间的相似度,而且还提供排序接口能从大量候选集中找到最相似的句子. (1)安装 pip install fuzzywuzzy (2)接 ...