I need to place search bar at the bottom of activity. How to implement it in android ?
-
http://stackoverflow.com/questions/14326565/two-action-bars-bottom-and-up-at-the-same-time – Nischal Hada May 07 '15 at 05:32
-
u can use relative layout and ur text field can be set to bottom using alignparentbottom(true) – Kushal Shukla May 07 '15 at 05:39
-
simplest way is that if you want to add only search functionality than without action bar its possible so you can add editbox at bottom of your layout and can write your logic for search from list – Ajay Pandya May 07 '15 at 05:40
-
What do you have till now ? Have you implemented it using `ActionBar` on top of screen ?? – Ankit Bansal May 07 '15 at 06:00
2 Answers
You can check in this link
http://forums.xamarin.com/discussion/8771/how-do-i-add-an-actionbar-to-the-bottom
Two action bars (Bottom and Up) at the same time?
add an ActionBar to the bottom and place search bar in there
<LinearLayout>
<RelativeLayout>
... (Top bar content can go here)
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<!--This is assuming you are going to use a listview, you can put anything here, just make sure to put the weight attribute into whatever you end up using-->
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:cacheColorHint="@color/black"
android:layout_weight="1" />
<!--Bottom bar layout below-->
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout2"
android:layout_weight="0" >
...Put your bottom bar content here...
</LinearLayout>
</LinearLayout>
</LinearLayout>
http://developer.android.com/guide/topics/ui/actionbar.html
Adding the Action Bar As mentioned above, this guide focuses on how to use the ActionBar APIs in the support library. So before you can add the action bar, you must set up your project with the appcompat v7 support library by following the instructions in the Support Library Setup.
Once your project is set up with the support library, here's how to add the action bar:
Create your activity by extending ActionBarActivity. Use (or extend) one of the Theme.AppCompat themes for your activity. For example:
<activity android:theme="@style/Theme.AppCompat.Light" ... >
Adding Action Items
res/menu/main_activity_actions.xml
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"/>
<item android:id="@+id/action_compose"
android:icon="@drawable/ic_action_compose"
android:title="@string/action_compose" />
</menu>
Then in your activity's onCreateOptionsMenu() method, inflate the menu resource into the given Menu to add each item to the action bar:
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu items for use in the action bar
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.main_activity_actions, menu);
return super.onCreateOptionsMenu(menu);
}
To request that an item appear directly in the action bar as an action button, include showAsAction="ifRoom" in the tag. For example:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:yourapp="http://schemas.android.com/apk/res-auto" >
<item android:id="@+id/action_search"
android:icon="@drawable/ic_action_search"
android:title="@string/action_search"
yourapp:showAsAction="ifRoom" />
...
</menu>
If there's not enough room for the item in the action bar, it will appear in the action overflow.
Using XML attributes from the support library Notice that the showAsAction attribute above uses a custom namespace defined in the tag. This is necessary when using any XML attributes defined by the support library, because these attributes do not exist in the Android framework on older devices. So you must use your own namespace as a prefix for all attributes defined by the support library. If your menu item supplies both a title and an icon—with the title and icon attributes—then the action item shows only the icon by default. If you want to display the text title, add "withText" to the showAsAction attribute. For example:
<item yourapp:showAsAction="ifRoom|withText" ... />

- 1
- 1

- 3,230
- 3
- 27
- 57
yes You can By Using Split Action bar in your application ... here is the link you can refer for it http://developer.android.com/guide/topics/ui/actionbar.html
And For A tutorial here
http://android-er.blogspot.in/2012/06/split-action-bar-for-android-4.html

- 10,632
- 4
- 45
- 55