Android课程---课下练习(表格、线性和相对布局)
2016-03-25 21:35
513 查看
1.表格布局
练习代码:
效果图:
2.线性布局
练习代码:
效果图:
3.相对布局
练习代码:
效果图:
ps:是不是发现最后一张效果图与前面2张不一样了,其实前面那2张才是正确的,那你就该问了,为什么最后一个不一样啊?事实是我试了好多办法,练习了好久,遗憾的是最后用相对布局方法还是没能做出来,只能放上我做的这张图了
练习代码:
<?xml version="1.0" encoding="utf-8"?> <TableLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:stretchColumns="4,2"> <TableRow> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="To:" android:layout_span="4"/> </TableRow> <TableRow> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="Subject:" android:layout_span="4"/> </TableRow> <TableRow> <EditText android:layout_width="wrap_content" android:layout_height="wrap_content" android:hint="Message:" android:layout_span="4" android:paddingBottom="340dp"/> </TableRow> <TableRow> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Reset" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Send" android:layout_weight="1"/> </TableRow> </TableLayout>
效果图:
2.线性布局
练习代码:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="To:"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Subject:"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Message:" android:paddingBottom="340dp"/> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Reset" android:layout_weight="1"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Send" android:layout_weight="1"/> </LinearLayout> </LinearLayout>
效果图:
3.相对布局
练习代码:
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="To:" android:id="@+id/to"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Subject:" android:layout_below="@+id/to" android:id="@+id/su"/> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Message:" android:layout_below="@+id/su" android:paddingBottom="350dp"/> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Reset" android:layout_alignParentBottom="true" android:id="@+id/re" android:layout_marginLeft="90dp" /> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Send" android:layout_alignParentBottom="true" android:layout_centerInParent="true" android:layout_toRightOf="@+id/re" /> </RelativeLayout>
效果图:
ps:是不是发现最后一张效果图与前面2张不一样了,其实前面那2张才是正确的,那你就该问了,为什么最后一个不一样啊?事实是我试了好多办法,练习了好久,遗憾的是最后用相对布局方法还是没能做出来,只能放上我做的这张图了
相关文章推荐
- android之常用知识点(一)
- [android] activity的生命周期
- Android高德地图API配置
- 找不到android.support.v4.view.ViewPager
- android 标题栏title开源库集成
- Android课程---布局管理器之相对布局(二)
- android开发带下划线的多行文本框
- ListView in fragment 列表视图的使用
- Android课程---布局管理器之相对布局(一)
- Android学习之ItemTouchHelper实现RecylerView的拖拽以及滑动删除功能
- Android课程---布局管理器
- Android权限监控拦截动态实现
- android Scroll学习
- 网易3.22号笔试(android)
- android 代码动态创建视图
- Android之ActivityManagerService浅谈
- Android 源码系列之<一>从源码的角度深入理解ImageView的ScaleType属性
- Android神奇跑马灯效果多种实现
- 简单的Android Studio 翻译插件
- Android之自定义控件入门