因为之后在其他页面中也将用到,所以这里我们采用自定义组件的方法,在fragment_home.xml中进行了调用:
<include
android:id="@+id/ic_main"
layout="@layout/custom_control_home_title"/>
查看custom_control_home_title.xml文件,如下:
<?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="60dp"
android:background="@color/pink_02">
<TextView
android:id="@+id/home_title_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Today"
android:textSize="26dp"
android:textColor="@color/white"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"/>
</RelativeLayout>
这样,在Today页面就可以看到顶部已经存在该标题栏了。
接着,我们为Today页面增加一个好看的背景,为了方便,这边直接使用了高清的图片作为了背景:
//背景
<ImageView
android:layout_below="@+id/ic_main"
android:layout_marginLeft="-25dp"
android:layout_width="500dp"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="@drawable/back_icon"/>
背景图片我已经上传到图床,供大家参考:
此时页面如下:
<