Reputation: 376
I'm trying to put a toolbar I created at the bottom of the screen in my Android app. This is what I have so far:
https://i.sstatic.net/3IFKw.jpg
I'm trying to move the black bar sitting there in the center at the bottom of the screen, but I can't figure out how to do it. This is the XML code I have in Android Studio so far:
<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>
Upvotes: 3
Views: 7206
Reputation: 93
Try setting the weight of the ScrollView
- with this:
android:layout_weight="1"
Upvotes: 3
Reputation: 57346
It will be much easier to use RelativeLayout
for this purpose:
<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>
Upvotes: 4