博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Android布局学习
阅读量:4605 次
发布时间:2019-06-09

本文共 1117 字,大约阅读时间需要 3 分钟。

习惯了Delphi/VB等RAD的拖放布局,使用Android的布局管理器还真不习惯.

例如要实现下面的界面布局: 

则需要如下设置:

 1 <LinearLayout
 2         android:layout_width="wrap_content"
 3         android:layout_height="wrap_content"
 4         android:orientation="horizontal" >
 5 
 6         <TextView
 7             android:id="@+id/textView1"
 8             android:layout_width="wrap_content"
 9             android:layout_height="wrap_content"
10             android:text="编码" />
11 
12         <EditText
13             android:id="@+id/editText1"
14             android:layout_width="match_parent"
15             android:layout_height="wrap_content"
16             android:layout_weight="2"
17             android:ems="10" >
18 
19             <requestFocus />
20         </EditText>
21         
22 
23         <TextView
24             android:id="@+id/textView2"
25             android:layout_width="wrap_content"
26             android:layout_height="wrap_content"
27             android:text="名称" />
28         
29 
30 
31 
32 
33         <EditText
34             android:id="@+id/editText2"
35             android:layout_width="wrap_content"
36             android:layout_height="wrap_content"
37             android:layout_weight="1"
38             android:ems="10" >
39 
40             <requestFocus />
41         </EditText>
42       

43     </LinearLayout> 

 

这里比较重要的属性是:

 

android:layout_weight

该属性是设置比重的,但设置好像是反的,TextView就不要设置这个属性了,要不然显示会比较令人郁闷的. 

 

转载于:https://www.cnblogs.com/GarfieldTom/archive/2012/05/02/2478443.html

你可能感兴趣的文章
JPA、JTA、XA相关索引
查看>>
查询语句的练习
查看>>
Java EE的map
查看>>
webdriver.py--解说
查看>>
windows 下配置Eclipse che
查看>>
SearchSploit
查看>>
关于C语言中的转义字符
查看>>
用正则表达式从网页里面提取视频地址
查看>>
JAVA线程优先级
查看>>
解决VC几个编译问题的方法——好用
查看>>
SPOJ #11 Factorial
查看>>
City Upgrades
查看>>
order set 有序集合
查看>>
“人少也能办大事”---K2 BPM老客户交流会
查看>>
关于七牛进行图片添加文字水印操作小计
查看>>
DataSource数据库的使用
查看>>
CentOS开启samba实现文件共享
查看>>
MSSQL使用sqlbulkcopy批量插入数据
查看>>
证明一个数能被3整除,当且仅当它的各位数的和能被3整除
查看>>
2018秋寒假作业4—PTA编程总结1
查看>>