1.建立一个xml布局文件,内容如下(名字为:title_layout.xml):
<?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="30dp"
android:orientation="vertical" >
<ImageView
android:id="@+id/title_iv1"
android:layout_width="match_parent"
android:layout_height="30dp"
android:contentDescription="@string/action_settings"
android:src="@drawable/ui_kaixinwang" />
</LinearLayout>
这个布局会在界面的上面显示一张图片.
效果如下:
2.建立另一个布局文件,名字为:activity_main.xml,内容如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include layout="@layout/title_layout"></include>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
</LinearLayout>
效果如下: