Android 中所有屏幕中的页脚
Footer in All screens in Android
我创建了一个页脚我想在所有屏幕上显示页脚我也显示 NavigationDrawer。如何在所有屏幕中显示页脚?
NavgaitionDrawer 中的 include 根本不显示页脚?有人可以帮我解决这个问题吗:
下面是显示工具栏等的 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="match_parent"
android:background="@color/button_material_light"
android:orientation="vertical" >
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/navigationHost"
android:layout_width="match_parent"
android:background="@color/button_material_light"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/parentContentHost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/contentHost"
android:layout_width="match_parent"
android:foreground="?android:windowContentOverlay"
android:layout_height="match_parent" />
</LinearLayout>
<include
layout="@layout/n_drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginRight="10dp" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
谢谢!
如果您有各种活动需要显示页脚,您可以在所有根 xml activity 文件中使用标签 <include layout="@layout/your_footer">
来实现。
根据您的评论,我了解到您真正想要的是将页脚添加到屏幕末尾,因此您需要完成以下操作:
<?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="match_parent"
android:background="@color/button_material_light"
android:orientation="vertical" >
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/navigationHost"
android:layout_width="match_parent"
android:background="@color/button_material_light"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/parentContentHost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/contentHost"
android:layout_width="match_parent"
android:foreground="?android:windowContentOverlay"
android:layout_height="0dp"
android:layout_weight="1"/>
<include
android:id="@+id/footer"
layout="@layout/footer" />
</LinearLayout>
<include
layout="@layout/n_drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginRight="10dp" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
但是,如果您想为每个 activity 添加此页脚,则需要在每个 activity 的 xml 中添加页脚,或者以编程方式将其添加到 BaseActivity class.
我创建了一个页脚我想在所有屏幕上显示页脚我也显示 NavigationDrawer。如何在所有屏幕中显示页脚?
NavgaitionDrawer 中的 include 根本不显示页脚?有人可以帮我解决这个问题吗:
下面是显示工具栏等的 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="match_parent"
android:background="@color/button_material_light"
android:orientation="vertical" >
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/navigationHost"
android:layout_width="match_parent"
android:background="@color/button_material_light"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/parentContentHost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/contentHost"
android:layout_width="match_parent"
android:foreground="?android:windowContentOverlay"
android:layout_height="match_parent" />
</LinearLayout>
<include
layout="@layout/n_drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginRight="10dp" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
谢谢!
如果您有各种活动需要显示页脚,您可以在所有根 xml activity 文件中使用标签 <include layout="@layout/your_footer">
来实现。
根据您的评论,我了解到您真正想要的是将页脚添加到屏幕末尾,因此您需要完成以下操作:
<?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="match_parent"
android:background="@color/button_material_light"
android:orientation="vertical" >
<include
android:id="@+id/toolbar"
layout="@layout/toolbar" />
<android.support.v4.widget.DrawerLayout
android:id="@+id/navigationHost"
android:layout_width="match_parent"
android:background="@color/button_material_light"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/parentContentHost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="@+id/contentHost"
android:layout_width="match_parent"
android:foreground="?android:windowContentOverlay"
android:layout_height="0dp"
android:layout_weight="1"/>
<include
android:id="@+id/footer"
layout="@layout/footer" />
</LinearLayout>
<include
layout="@layout/n_drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_marginRight="10dp" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
但是,如果您想为每个 activity 添加此页脚,则需要在每个 activity 的 xml 中添加页脚,或者以编程方式将其添加到 BaseActivity class.