一、实验目标
如何制作一个简单的app首页,了解父布局、线性布局的使用
二、实验步骤
1、首先创建他的父布局,同时将图片素材导入mipmapp文件,注意命名不能含有数字或者大写字母
2、新建ScrollView.
3、创建Scroll VIew内部父布局
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" >
<ScrollView android:layout_width="match_parent" android:layout_height="match_parent"> <LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> </LinearLayout> </SrollView> </LinearLayout>
4、创建顶部首页显示显示栏
设置宽高、文字、字体、样式、颜色、字体居中等:
<LinearLayout android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <TextureView android:layout_width="match_parent" android:layout_height="50dp" android:gravity="center" android:text="首页" android:textColor="#333" android:textSize="18dp" android:textStyle="bold" />
5、创建顶部照片
设置宽高、src加载、给图片设置边距
android:textColor="#333" android:textSize="18dp" android:textStyle="bold" /> <ImageView android:layout_marginRight="10dp" android:layout_marginLeft="10dp" android:src="@mipmap/testimg" android:layout_width="match_parent" android:layout_height="200dp"/>
6、设置菜单栏模块
(1)创建一个横向的LinearLayout作为 菜单栏的父布局
(2)再创建一个LinearLayout来作为单个按钮的父布局
(3)创建图片按钮,设置其属性
(4)设置按钮底部文字和其属性
<LinearLayout android:layout_marginTop="0dp" android:layout_marginRight="10dp" android:layout_marginLeft="10dp" android:weightSum="4" android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation="vertical" android:layout_weight="1" android:layout_width="0dp" android:layout_height="100dp"> <ImageView android:layout_marginTop="10dp" android:layout_gravity="center_horizontal" android:background="@mipmap/testicon" android:layout_width="50dp" android:layout_height="50dp"/> <TextView android:layout_marginTop="10dp" android:gravity="center" android:text="验房" android:layout_width="match_parent" android:layout_height="wrap_content"/> </LinearLayout>
7、消息模块的实现
(1)创建一个横向的LinearLayout作为菜单栏的父布局