我有一个包含该结构的BaseActivity:重新核准布局butterknife
<!-- activity_base -->
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/container_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<include
layout="@layout/tool_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true" />
<include
layout="@layout/content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/tool_bar"
android:layout_above="@id/bottom_navigation" />
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
app:menu="@menu/bottom_navigation_menu" />
</RelativeLayout>
在我BaseActivity
我控制BottomNavigationView
。我创建了几个活动,我想利用包含内容并只加载该活动的内容。 今天该项目正在使用butterknife
Java。而且该项目越来越庞大,因为它正在复制每个子活动的顶层结构BaseActivity
。我想重构(以最好和最快的方式)该项目,以便只有一个 activity_base.xml
和其他活动仅控制其内容(content.xml
)。 我看到一些使用ViewStub
和另一个描述<merge>
但我不明白如何在项目中轻松应用概念,因为许多使用活动和片段,我的项目只与活动。
之后调用它的原因是否可以为所有活动使用完全相同的layout.xml? –