布局相关的知识点
来源:互联网 发布:网游推荐知乎 编辑:程序博客网 时间:2024/06/05 08:20
1、
android:gravity="center"//一般指文字在控件中的对齐方式 android:layout_gravity="right" //一般指控件在布局中的对齐方式
2、使用android:layout_weight去分配控件占用的空间时,规范写法试讲相应的尺寸设置为0,通过android:layout_weight来设置各元素所占用的比例。各个控件的android:layout_weight占个控件总的android:layout_weight和的比例。
<LinearLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:orientation="horizontal" > <EditText android:id="@+id/et1" android:layout_width="0dp" android:layout_weight="1" android:layout_height="wrap_content" android:hint="type something here" android:maxLines="2" /> <Button android:layout_height="wrap_content" android:layout_width="wrap_content" android:text="确定" /> </LinearLayout>
3、相对布局
(1)
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.david.firstcode_ui.Main2Activity"> <Button android:id="@+id/bt1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" android:layout_above="@id/bt5" android:layout_toLeftOf="@id/bt5" /> <Button android:id="@+id/bt2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button2" android:layout_above="@id/bt5" android:layout_toRightOf="@id/bt5" /> <Button android:id="@+id/bt3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" android:layout_below="@id/bt5" android:layout_toLeftOf="@id/bt5" /> <Button android:id="@+id/bt4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" android:layout_below="@id/bt5" android:layout_toRightOf="@id/bt5" /> <Button android:id="@+id/bt5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" android:layout_centerInParent="true" /></RelativeLayout>
(2)
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.david.firstcode_ui.Main2Activity"><Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button2" android:layout_alignParentRight="true" android:layout_alignParentTop="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" android:layout_alignParentLeft="true" android:layout_alignParentBottom="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" android:layout_alignParentRight="true" android:layout_alignParentBottom="true" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button1" android:layout_centerInParent="true" /></RelativeLayout>
阅读全文
0 0
- 布局相关的知识点
- 网页布局相关知识点整理
- 页面布局技巧&&js相关知识点&&乱七八糟
- EJB的相关知识点
- EJB的相关知识点
- Session的相关知识点
- XML的相关知识点
- ROWNUM的相关知识点
- 字符串相关的知识点
- linux相关的知识点
- scanf的相关知识点
- 类相关的知识点
- jquery的相关知识点
- jQuery的相关知识点
- Selenium2的相关知识点
- JTable相关的知识点
- PHP的相关知识点
- 通知的相关知识点
- Python os.walk的用法与举例
- leetcode26 Remove Duplicates from Sorted Array 去重已排序列表
- CC2640
- http错误代码
- 欢迎使用CSDN-markdown编辑器
- 布局相关的知识点
- ajax post请求发送json数据报错unexpected token in json at position的问题解决
- redis 事务
- Linux hung task detect
- 【转载】jxl导出excel(合并单元格)
- VS2013 错误1error C4996: 'wcstok': This function or variable may be unsafe. Consider using wcstok_s i
- 开发框架-Spring-Profile的配置、激活和读取
- linux下wifi编程(基于netlink和nl80211.h)
- 总结