【问题标题】:Android ButtonBar Taking Up All Screen SpaceAndroid ButtonBar 占用所有屏幕空间
【发布时间】:2016-04-09 13:04:57
【问题描述】:

我正在尝试使用 roughike 底部栏实现底部导航栏:https://github.com/roughike/BottomBar

这是我得到的图像(在我的手机上):

我想将我的工具栏保持在设备屏幕的顶部。当我运行应用程序时,底部栏几乎占据了我的 MainActivity 的所有空间。 CoordinatorLayout 是否必须是所有元素的父元素?这是我的 XML 布局文件:

    <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_margin="0dp"
    android:layout_marginBottom="0dp"
    android:padding="0dp"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="allblacks.com.ibaleka_android_prototype.MainActivity">
    <android.support.v7.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id = "@+id/MainActivityToolbar"
        android:background="@color/colorPrimary"
        android:elevation="5dp"
        >
        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:id = "@+id/MainActivityImageView"
            android:layout_marginRight="5dp"
            android:layout_marginLeft="1dp"/>
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            style="@style/ToolbarTextView"
            android:id = "@+id/MainActivityTextView"
            android:textAlignment="center"
            />
    </android.support.v7.widget.Toolbar>
    <android.support.design.widget.CoordinatorLayout
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:id = "@+id/mainActivityMenu"
        >
        <android.support.v4.widget.NestedScrollView
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            >
            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:id = "@+id/MainActivityContentArea"
                >
            </FrameLayout>
        </android.support.v4.widget.NestedScrollView>
    </android.support.design.widget.CoordinatorLayout>
</RelativeLayout>

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    是的协调器布局需要是父布局。 Coordinator Layout Documentation查看链接了解更多详情

    【讨论】:

      猜你喜欢
      • 2015-02-12
      • 1970-01-01
      • 1970-01-01
      • 2021-04-21
      • 1970-01-01
      • 2020-11-03
      • 1970-01-01
      • 1970-01-01
      • 2020-06-09
      相关资源
      最近更新 更多