【发布时间】:2016-02-12 22:49:47
【问题描述】:
我的应用由多个活动组成,它们都有一个共同的布局,即抽屉布局,有一个工具栏,但它们有不同的主要内容。具体来说,它们的完整布局如下
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/relative_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<android.support.v7.widget.Toolbar
android:id="@+id/action_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
/>
.......main content, this is different for each activity..........
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
由于共享组件是在“父级”定义的,我不确定如何构建这些布局,以便通用布局只定义一次。有可能实现吗?谢谢。
【问题讨论】: