Android的前生今世,感兴趣的小伙伴点击百度一下吧
百度回来的各位,接下来我们进入项目实战学习
首先我们就先从看得到的入手,探究UI开发吧——实战两个常用基本布局
1. 线性布局(LinearLayout)——本篇讲解
2. 相对布局(RelativeLayout)——下篇
简单说说线性布局的特点:
1.线性布局是将放入其中的组件按照垂直或水平方向来布局
2.控制放入其中的组件横向排列或纵向排列
3.在线性布局中,每一行(针对垂直排列)或每一列(针对水平排列)中只能放一个组件
4.Android的线性布局不会换行,当组件一个挨着一个排列到窗体的边缘后,剩下的组件将不会被显示出来
使用线性布局(LinearLayout)来仿一个微信我的界面吧
——界面布局解析图及效果图——
相信这个界面还原度可以高达99.999999999999999%
贴上界面的完整代码
仅用一种布局完成,导致代码比较复杂,请结合上面的界面解析图看哦
<?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"
android:background="#F1EEEE"
>
<!--装载相机按钮的线性布局-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff"
android:orientation="vertical"
>
<!--相机按钮-->
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:src="@drawable/photo"
android:layout_gravity="right"
android:layout_marginTop="12dp"
android:layout_marginRight="12dp"
/>
</LinearLayout>
<!--个人信息栏线性布局水平-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="120dp"
android:orientation="horizontal"
android:gravity="center_vertical"
android:background="#fff"
>
<!--头像-->
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="@drawable/abc"
android:layout_marginLeft="15dp"
/>
<!--线性布局垂直-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp"
>
<!--网名-->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Lionel Wang"
android:textColor="#000"
android:textSize="24sp"
/>
<!--线性布局水平-->
<LinearLayout
android: