总结 2017-12-08
来源:互联网 发布:域名对比 编辑:程序博客网 时间:2024/05/16 11:36
因为现阶段我们需要好好好掌握布局之间的使用,所以今天的练习内容有两个分别是导航栏和一个简单的登录界面:
第一个底部导航界面我运用的是线性布局里面镶套了几个相对布局,因为我只需要做下面的部分,所以我把屏幕分割为两份,运用权重,分别设定上下比例为9:1。
然后在下面的导航栏我们可以看到,导航栏分两个部分,图还有文本,所以同理,分割两个线性布局,分别进行编写图片和文本。
包含图片的线性布局,我分别把每张图应用在相对布局里面,这样就能简单快捷的分配每个图片之间的距离,实现最快的编辑效果,其次设定图片的格式为android:layout_centerInParent="true" 居中显示。文本框同理。具体代码截图如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:background="#ffffff"> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="1dp" android:layout_weight="9" android:background="#ffffff" android:orientation="vertical"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/home_off" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/shaix_off" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:id="@+id/gouwuche" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:src="@drawable/gouwuc_on" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:src="@drawable/my_off" /> </RelativeLayout> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <TextView android:id="@+id/textView" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="首页" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="分类" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:textColor="#CC0001" android:text="购物车" /> </RelativeLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1"> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:gravity="center" android:text="我的" /> </RelativeLayout> </LinearLayout> </LinearLayout></LinearLayout>
第二个简单的登录界面,运用的是线性布局,每行分为三个部分,分别是 TextViewEditTextTextView 同理运用的权重比,调整内边距实现第一个文本框距离屏幕的宽度,
格式为居中,其余两行复制粘贴修改即可。代码如下:
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:layout_width="match_parent" android:layout_height="70dp" android:weightSum="10" android:background="#ffffff"> <TextView android:id="@+id/textView" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="2.5" android:paddingLeft="45dp" android:text="姓名" android:textSize="15dp" /> <EditText android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="5.5" android:hint="请输入姓名" android:textSize="15dp" /> <TextView android:id="@+id/textView2" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="2" /> </LinearLayout> <LinearLayout android:layout_marginTop="1dp" android:layout_width="match_parent" android:layout_height="70dp" android:background="#ffffff"> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="2.5" android:text="所学专业" android:textSize="15dp" android:paddingLeft="15dp"/> <EditText android:id="@+id/editText" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="5.5" android:hint="请输入专业" android:textSize="15dp" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="2" /> </LinearLayout> <LinearLayout android:layout_marginTop="1dp" android:layout_width="match_parent" android:layout_height="70dp" android:background="#ffffff"> <TextView android:id="@+id/textView3" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="2.5" android:paddingLeft="45dp" android:text="班级" android:textSize="15dp" /> <EditText android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="5.5" android:hint="请输入班级" android:textSize="15dp" /> <TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center" android:layout_weight="2" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:background="#ffffff"></LinearLayout></LinearLayout>
阅读全文
0 0
- 总结 2017-12-08
- 2017-05-08 总结
- 总结 2017-12-12
- 12-11-08 总结
- 总结-2017/10/12
- 总结-2017/11/12
- 总结 2017-12-07
- 总结-2017/12/7
- 总结-2017/12/10
- 总结 2017-12-11
- 总结 2017-12-13
- 总结 2017-12-14
- 总结-2017/12/15
- 总结 2017-12-15
- 总结-2017/12/20
- 总结 2017-12-19
- 总结 2017-12-21
- 总结 2017-12-22
- 判断ListView、WebView、ScrollView到达顶部和底部
- Maven项目的安装及在Eclipse的配置
- Hive设置map和reduce的个数
- 警惕!针对企业的钓鱼邮件APT攻击大面积爆发
- linux 路由表设置 之 route 指令详解
- 总结 2017-12-08
- [platform]新旧内核的device设备注册对比
- 操作系统实验,用C或者C++实现银行家算法
- 使用SpringBoot开发REST服务
- 数据结构C语言版:一元多项式相乘
- bzoj1011
- node socket 简单聊天室
- 关于MySQL事物处理的问题
- Linux下修改主机IP地址的方法