How to add a custom view top the android navigation bar like above image. when user click on the action bar need to push the main content down and add the custom layout top of the action bar.please how to accomplish this any one suggest a solution
Thanks
Rahul
An easy solution would be to use those views in the actual ActionBar like this: http://developer.android.com/guide/topics/ui/actionbar.html#ActionView. And then take all your layouts and put them inside a RelativeLayout and set their android:layout_below="" to a layout that corresponds to the ActionBar you want to use. So in a step by step way:
Create an action_bar.xml that has the items you want your actionbar to have (ImageViews or Buttons, w/e)
Include this layout in all the Layouts you will use (or in your main layout if you're using Fragments to display content).Like this:
<include layout="#layout/action_bar"
android:id="#+id/action_bar"
android: ... />
Make your Layout position itself below this layout (Using a FrameLayout for example)
<FrameLayout
android:id="#+id/content_frame"
android:layout_below="#+id/action_bar"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
Include the ActionViews (Spinner and tabs) in the ActionBar like it's taught in the link up there.
Related
I'm new to Android development and I have to build an Android version of a iOs app. I have to build an horizontal menu in the bottom of the screen. Something like MOVIES|TV SHOWS|PERSONAL VIDEOS in this image
How do you suggest me to proceed? If I did an activity layout with a tabbed o linear layout at the bottom and fragments for the above contents?
#Ivan Lasorsa :
You can use ViewPager Fragment as main layout and for individual pager views we use Fragments. The tabs are part of Action Bar.
Swipe-view should consume the entire layout, then your layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.view.ViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
So please take a look Android Tab Layout with Swipeable Views Here . I hope it will helps you .
It's the tabbed activity, here is the doc ;)
I don't recommend bottom tab bar
because it causes the wrong touch
Pure-Android : http://developer.android.com/design/patterns/pure-android.html
but if you have to implement, you can read to
https://stackoverflow.com/a/7431480/2530660
I want to implement Toolbar something like the following design. It is called flexible toolbar and card toolbar
I tried implementing the custom view inside toolbar. I achieved something like below image!
Now what I did is added custom view to Toolbar but I want to implement like first image. I want to create a card like view on tool bar with all those action views.
To achieve that (As per my view) I can create a custom layout and add it over tool bar. Then I should attach another layout below the toolbar.
My question is whether I should do it as what I said or is there any other simpler way I can implement it?
You should use 2 ToolBars - One for the "ActionBar" and one for the CardView
<FrameLayout>
<ToolBar /> //the Actionbar ToolBar
<CardView layout_marginTop="?attr/actionBarSize">
<ToolBar /> //the Toolbar with the Menu items
...
</CardView>
</FrameLayout>
I have a custom action bar for which I have used Sherlock Implementation and I tend to find that the tab widget is placed at the top every time rather than in the middle.
I have tried the following in XML but it seems to set the action bar at the top :
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
></TabWidget>
I want it somewhere in the middle. I have provided with an example image below :
As you can clearly see that the action bar is located at the top which is not what I want. So,how do I place it after the Followers list. Any ideas ??
Is the parent View of you TabWidget a LinearLayout? If so, you may try your luck with a RelativeLayout.
I have created custom tab bars by following the post given below:
How to create a Tab-like UI in Android?
No I need to display a set on sub menu when the center tab (actually it is a button) is clicked. I need the sub menu to pop up like in this drawing (sub menu should be above my main layout):
I believe that this can be achieved by putting an additional layout above the custom tab bar in which a set of buttons can be placed one after another. But I am not sure which layout needs to be used and how I can get the same style in the drawing. Please help me to find a solution.
you're correct with just adding another layout above the button you want to open it, and then setting its visibility to gone until you want to animate in it.
a regular LinearLayout would work fine, and then adding 4 buttons to it would work as well, then you would want to make sure those buttons used the same styles as the built-in android menu buttons (or style it yourself) but check out some of the built in styles here
example:
your activity
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
//all your other activity layout stuff goes here
<!--add your new menu-->
<LinearLayout
android:id="#+id/my_menu_layout"
android:visibility="gone"
... />
<Button
android:id="#+id/menu_btn_1"
style="#android:style/Widget.Holo.ActionButton.TextButton" //as example of built-in style
... />
//more buttons
</LinearLayout>
then in your activity class, assign an onClickListener to the button that will toggle the menu and animate the view in
//animation xml you make
Animation inFromBottom = AnimationUtils.loadAnimation(this, R.anim.layout_in_bottom);
mMenuLayout.startAnimation(inFromBottom);
mMenuLayout.setVisibility(View.VISIBLE);
now your view will animate in and you can go about adding onClick listeners to the buttons
I am not quite sure what kind of layout Gmail is using in Android.
I suppose they use a floating ViewGroup.
But for the menu on the top and bottom I really need somebody point me how to make that.
I suggest you to use the Sherlock ActionBar:
http://actionbarsherlock.com/
This allows you to easily develop an application with an action bar for every version of Android from 2.x and up.
In the sample app you can find the code to achieve what you are looking for under "Split Action Items". The idea is that you add actions from the menu as usual, but writting the following line in your manifest activity:
android:uiOptions="splitActionBarWhenNarrow"
You can create a menu which will sit on the bottom of a listview using the <RelativeLayout> tag like so
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ListView
android:layout_height="wrap_content"
android:layout_width="fill_parent" android:id="#android:id/list"
android:listSelector="#android:color/transparent"
android:layout_above="#+id/footer" />
<include android:id="#+id/footer" android:layout_height="wrap_content"
layout="#layout/mymenu" android:layout_width="fill_parent"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true" >
</include>
</RelativeLayout>
mymenu will contain a linearlayout with something like a tablelayout with a few rows (which can be textviews, imageviews, etc.) The table will sit at the bottom of your screen and the listview will be in a frame which starts at the top of the screen and ends at the top of the menu (no overlap)
You could also do the same for the top of the screen by simply having the listview say layout_below="#+id/header" instead of layout_above"#+id/footer" (or do both!)
This is covered on android. You have to implement a "split action bar". Note that it works in potrait view and disappears when you switch to landscape.
Android Action Bar
It looks like a custom ActionBar implementation. If you put icons in a normal ActionBar and there is not enough space to display them, android creates a bottom bar on its own and display the icons there.
I had a similar application and I chose to put my own custom bar there instead of implementing ActionBar