part1:我的界面实现-头部xml布局的实现
在fragment_me.xml中
下面贴代码:
<?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">
<RelativeLayout
android:id="@+id/layout_me_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#008CC9">
<Button
android:id="@+id/btn_login"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@mipmap/login_btn"
android:layout_centerHorizontal="true" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_below="@+id/btn_login"
android:layout_marginBottom="5dp"
android:layout_marginTop="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@mipmap/me_menu_sail" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="优惠券" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@mipmap/me_menu_yh" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="折扣券" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@mipmap/me_menu_go" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="购物券" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
part2:滚动列表的实现
将做好的列表放在scrollview中
注意:可能会使底部显示不全,被挡住
只有设置scrollview的marginBottom=“一个距离”,距离底部的距离约大,就可以使它底部的内容跑上来了
<?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">
<!--头部-->
<RelativeLayout
android:id="@+id/layout_me_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#008CC9">
<Button
android:id="@+id/btn_login"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:background="@mipmap/login_btn" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/btn_login"
android:layout_marginBottom="5dp"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@mipmap/me_menu_sail" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="优惠券" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@mipmap/me_menu_yh" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="折扣券" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:background="@mipmap/me_menu_go" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="购物券" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<!--滚动列表-->
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="80dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/list_my_menu" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center">
<TextView
android:id="@+id/txt_me"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="我的订单"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txt_me"
android:layout_marginRight="10dp"
android:background="#D8DEDD">
</View>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/list_save" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center">
<TextView
android:id="@+id/txt_my_save"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="我的收藏"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txt_my_save"
android:layout_marginRight="10dp"
android:background="#D8DEDD">
</View>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/list_pwd" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center">
<TextView
android:id="@+id/txt_pwd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="我的口令"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txt_pwd"
android:layout_marginRight="10dp"
android:background="#D8DEDD">
</View>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/list_my" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp">
<TextView
android:id="@+id/txt_my"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="我的锦囊"
android:textSize="18dp" />
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="6dp"
android:layout_below="@+id/txt_my"
android:layout_marginTop="5dp"
android:background="#D8DEDD"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/list_safe_center" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center">
<TextView
android:id="@+id/txt_safe_center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="安全中心"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txt_safe_center"
android:layout_marginRight="10dp"
android:background="#D8DEDD">
</View>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/list_address" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center">
<TextView
android:id="@+id/txt_adress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="常用地址"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txt_adress"
android:layout_marginRight="10dp"
android:background="#D8DEDD">
</View>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/list_service" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center">
<TextView
android:id="@+id/txt_service"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="客服中心"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txt_service"
android:layout_marginRight="10dp"
android:background="#D8DEDD">
</View>
</RelativeLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/list_sug" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center">
<TextView
android:id="@+id/txt_sug"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="意见反馈"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txt_sug"
android:layout_marginRight="10dp"
android:background="#D8DEDD">
</View>
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="6dp"
android:layout_below="@+id/txt_my"
android:layout_marginTop="5dp"
android:background="#D8DEDD"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="5dp"
android:src="@mipmap/list_setting" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center">
<TextView
android:id="@+id/txt_setting"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:text="设置"
android:textSize="18dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txt_setting"
android:layout_marginRight="10dp"
android:background="#D8DEDD">
</View>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>