【问题标题】:Always have an footer bar at end of screen?屏幕末尾总是有一个页脚栏?
【发布时间】:2015-01-13 09:46:35
【问题描述】:

我必须始终在屏幕末尾显示一些按钮。我的应用程序有多个活动,因此我希望在所有活动中都易于实现。我知道我可以在 xml 中包含页脚。但问题是我不希望页脚覆盖其他内容。我希望能够使用这样的东西:

<include layout="@layout/footer" /> 

然后代码将为页脚“腾出空间”。因此,例如,如果我有列表视图,则列表视图不会位于页脚下方,而是列表视图渲染区域将在页脚开始的位置结束。

正如我之前提到的,页脚有按钮,无论它当前处于哪个活动中,它们都必须触发一个函数。另外,如果可以以某种方式使用,我想使用:

imageButton = (ImageButton) findViewById(R.id.imageButton);
bm = BitmapFactory.decodeFile(path);
imageButton.setBackground(new BitmapDrawable(bm));

每个按钮。

所以总结一下。有什么方法可以始终在屏幕末尾显示布局触发功能?

提前致谢!

【问题讨论】:

  • 我建议你不要这样做。底部有按钮的应用程序在 Android 中很痛苦,因为这是主页、返回和菜单按钮所在的位置。不要复制iOS。用 Android 的方式来做。

标签: android footer


【解决方案1】:

为什么不使用 Layouts 拆分视图?像这样的:

<?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">

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="match_parent"
        android:layout_height="510dp"></LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:orientation="horizontal"
        android:layout_height="60dp"
        android:layout_gravity="center_horizontal"></LinearLayout>
</LinearLayout>

除此之外,我记得曾经读过您可以强制 ActionBar 位于底部。也许你可以使用它?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-21
    • 2014-07-18
    • 2021-08-02
    • 1970-01-01
    • 2016-11-04
    相关资源
    最近更新 更多