Android布局文件经验
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布局文件经验的更多相关文章
- Xamarin Android布局文件没有智能提示
Xamarin Android布局文件没有智能提示 在Visual Studio 2015中,Android项目的Main.axml文件没有智能提示,不便于布局文件的编写.解决办法:(1)从Xamar ...
- Android布局文件夹引起的问题
Android 运行到setContentView(R.layout.splash); 总是出现如下的错误: java.lang.RuntimeException: Unable to start a ...
- android 布局文件中xmlns:android="http://schemas.android.com/apk/res/android"
http://blog.163.com/benben_long/blog/static/199458243201411394624170/ xmlns:android="http://sch ...
- android 布局文件中控件ID、name标签属性的命名包含“@”、“.”、“+”等等符号的含义
1. 在项目的根目录有个配置文件“AndroidManifest.xml”,是用来设置Activity的属性的如 <?xml version="1.0" encoding=& ...
- Android布局文件的载入过程分析:Activity.setContentView()源代码分析
大家都知道在Activity的onCreate()中调用Activity.setContent()方法能够载入布局文件以设置该Activity的显示界面.本文将从setContentView()的源代 ...
- Android布局文件layout.xml的一些属性值
第一类:属性值 true或者 false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 andr ...
- Android布局文件-错误
View requires API level 14 (current min is 8): <?xml version="1.0" encoding="utf-8 ...
- android 布局文件 ScrollView 中的 listView item 显示不全解决方案
import android.content.Context;import android.util.AttributeSet;import android.widget.ListView; /** ...
- 【Android】Android布局文件的一些属性值
第一类:属性值 true或者 false android:layout_centerHrizontal 水平居中 android:layout_centerVertical 垂直居中 androi ...
随机推荐
- BZOJ 4810 莫队+bitset
思路: 看完这道题根本没有思路啊.... 然后我就膜拜了一波题解... 这神tm乱搞思路 维护两个bitset 第一个bitset代表当前区间哪些数出现过 第二个bitset是 maxp-p出现过 差 ...
- objc_setAssociatedObject获取cell上button对应所在的行
#import <UIKit/UIKit.h> @interface TestCell : UITableViewCell @property (weak, nonatomic) IBOu ...
- ThinkPHP5中的助手函数
load_trait:快速导入Traits,PHP5.5以上无需调用 /** * 快速导入Traits PHP5.5以上无需调用 * @param string $class trait库 * ...
- 关于AS使用git的那些奇葩事儿
首先致谢: http://blog.csdn.net/a10615/article/details/52135617, 我们不生产代码, 我们只做大自然的搬运工! 总结 1. 首次无法push问题: ...
- WIN10 64位下VS2015 C#直接添加 halcon 12导出的CS文件实现视觉检测
C# halcon 12 联合编程的 实例 1.先调试好halcon程序,我以读取图片的程序为例.
- Percona Xtrabackup备份及恢复
1. http://www.percona.com/software/percona-xtrabackup下载并安装 2. 全量备份 a.全量备份到制定目录 innobacku ...
- sql 排序
select count(*) from vote group by contents PERCENT * from vote order by contents)as A group by cont ...
- c# cookie帮助类
using System; using System.Collections.Generic; using System.Text; using System.Web; namespace Matic ...
- Python-通过configparser读写配置文件
Python读写配置文件: 1.创建配置文件(文件名以.conf或.ini结束的文件表示配置文件) 2.导入所需模块 OS, configparser >>> import os & ...
- javaee IO流作业
package Zy; import java.io.Serializable; public class Student implements Serializable{ private stati ...