I have a BaseLayout
, the BaseLayout
is a ParentLayout
for other layouts. In other words, the other Layouts inherit/include it. The BaseLayout
has DrawerLayout
(shared for all layouts) but each Activity
has a different content.
My BaseLayout looks like this:
<?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">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/myDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!--Main Content-->
<LinearLayout
android:id="@+id/rootLinearLayout"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical">
<!--Content-->
<!--must add Other Layout elements there
must add Other Layout elements there
must add Other Layout elements there
must add Other Layout elements there
must add Other Layout elements there !-->
</LinearLayout>
<!-- Left Navigation Derawer -->
<LinearLayout
android:id="@+id/llLeftDrawer"
android:orientation="vertical"
android:layout_width="240dp"
android:layout_height="match_parent"
android:background="?attr/colorAccent"
android:padding="15dp"
android:layout_gravity="right">
<!-- Left Navigation Derawer Content-->
<TextView
android:text="Categories"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/textView1"
android:gravity="center"
android:textColor="#FFFFFF"
fontPath="fonts/MobileFont.ttf" />
<ListView
android:id="@+id/lvLeftMenu"
android:layout_height="match_parent"
android:layout_width="match_parent" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
and included in Postlayout
like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<include
layout="@layout/BaseLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
How can I add PostLayout
elements into the BaseLayout
LinearLayout
id rootLinearLayout
?
postLayout
element is this:
<LinearLayout
android:orientation="vertical"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/linearLayout1">
<TextView
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtPostTitle"
android:gravity="right" />
<TextView
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtPostDate"
android:gravity="right" />
<android.webkit.WebView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/wbvPostContent" />
</LinearLayout>