Reputation: 179
How could i put a Button
bar at the top or bottom of my android application?
That is, in the Activities
of my application I want the Button
bar in all of them.
A bar with quick access Buttons
(a button Home, another Exit button ... etc)
How can this be implemented?
thank you very much
Upvotes: 0
Views: 223
Reputation: 340
What you can do is, you can create a new class for that button bar and include that UI element in all your screens. The concept is called fragment. If you change code for fragment once it will be reflected on all other screens. Here is tutorial on fragments.
Upvotes: 0
Reputation: 34554
Using a RelativeLayout
you can place Views
that are at the bottom of the parent View
or the top of the parent View
.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/relativelayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="left top of parent" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="right top of parent" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="@+id/button3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="left bottom of parent" />
<Button
android:id="@+id/button4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="right bottom of parent" />
</LinearLayout>
</RelativeLayout>
Upvotes: 1