Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/182.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何将Android工具栏与屏幕底部对齐?_Android_Xml_Android Layout - Fatal编程技术网

如何将Android工具栏与屏幕底部对齐?

如何将Android工具栏与屏幕底部对齐?,android,xml,android-layout,Android,Xml,Android Layout,我正在尝试将我创建的工具栏放在Android应用程序的屏幕底部。这就是我到目前为止所做的: 我试图移动屏幕底部中间的黑色条,但我不知道怎么做。这是到目前为止我在Android Studio中使用的XML代码: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_pa

我正在尝试将我创建的工具栏放在Android应用程序的屏幕底部。这就是我到目前为止所做的:

我试图移动屏幕底部中间的黑色条,但我不知道怎么做。这是到目前为止我在Android Studio中使用的XML代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"

    >
    <!--Begin Top Bar-->
    <Toolbar
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="?attr/colorPrimary"
        >

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Lbs"
            android:id="@+id/tvLbs"
            android:textSize="17dp"
            android:textColor="#000000"
            android:layout_gravity="left"/>

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center"
            android:src="@drawable/logo"/>
        </Toolbar>

    <!--End Top Bar-->

    <ImageView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/week1"
        />

    <!--Begin all scrollable stuff-->
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content">

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:orientation="vertical">


            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@string/total"
                android:textSize="45dp"
                android:layout_gravity="center"
                android:id="@+id/tvDisplay"
                />

            <Button
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:text="Add one"
                android:layout_gravity="center"
                android:textSize="20dp"
                android:id="@+id/bAdd"
                />

            <Button
                android:layout_width="250dp"
                android:layout_height="wrap_content"
                android:text="Subtract one"
                android:layout_gravity="center"
                android:textSize="20dp"
                android:id="@+id/bSubtract"
                />

        </LinearLayout>

    </ScrollView>

    <!--End Scrollable stuff-->

    <Toolbar
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:alignParentBottom="true">

        </Toolbar>

</LinearLayout>

尝试设置
滚动视图的权重
-如下所示:


android:layout\u weight=“1”
为此,使用
RelativeLayout
会容易得多:

<RelativeLayout ...>
    <!-- top toolbar -->
    <Toolbar
        android:id="@+id/top_toolbar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:background="?attr/colorPrimary"
    >

        ...

    </Toolbar>

    <ImageView
        android:id="@+id/image"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/top_toolbar"
        android:src="@drawable/week1"
    />

    <!-- bottom toolbar -->
    <Toolbar
        android:id="@+id/bottom_toolbar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="#000000"
        android:layout_alignParentBottom="true">

    </Toolbar>

    <!-- scrollable pane -->
    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@id/image"
        android:layout_above="@id/bottom_toolbar">

        ...

    </ScrollView>
</RelativeLayout>

...
...

真管用!现在看起来像这样,正是我想要的样子: