How can I add tabs to a view outside the action bar? - android

I have a layout where I need tabs inside a sub-layout, not in the action bar. I.e., The tabs do not apply to the entire screen display, only to one of the panes.
How can I do this in Android 4.0+?

You can do this using the support library and a FragmentTabHost. Google has an example here. In your layout file you can embed the android.support.v4.app.FragmentTabHost that's shown in the example inside another layout, such as a pane.
Another option is to use scrollable tabs. They also can be imbedded anywhere in a layout. Google gives a code example here. The view that you will imbed in your pane is the android.support.v4.view.ViewPager with a android.support.v4.view.PagerTitleStrip as it's subview. This example also has a sample project that you can download (the example project doesn't have the scrollable tabs imbedded inside another layout, but it's a good starting point).

Related

How to integrate tabs inside a layout?

I would like to use the component tabs Android but within a layout. In fact, I would like the tabs is not sticking to my action bar in order to display information between.
Here is an example image of what I would get:
You can add tabs inside a FragmentTabHost
Here is a tutorial implementing this
http://www.betteropts.com/fragmenttabhost-tutorial-using-fragment-as-tab-content-and-keep-navigation-history-for-each-tab/

Android sherlock actionbar tabs alignment

I'm using Android sherlock fragment tabs for creating a layout for swiping the tabs.
Now what I want to do is put the tabs below a relative layout , but the tabs headers are appearing at the top while it's content is appearing where it should be.
You may use standalone tabs widget like https://github.com/JakeWharton/Android-ViewPagerIndicator
or move existing tabs using technique (really hack) described at http://kriomant.blogspot.ru/2013/08/navigation-drawer-tabs-overlap.html
But in case of hack current tab indicator will still be drawn at the bottom. I didn't investigate whether it is possible to move it.

Android: ActionBar with fixed bottom layout

I am trying to make an app which the main screen is an tabbed interface, and bellow the tab control there is a fixed strip of controls.
My first try, was adding into my XML another linear layout bellow the android.support.v4.view.ViewPager and setting actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); . This hides the layout at the bottom.
When I try NAVIGATION_MODE_STANDARD I see the layout at the bottom, but the app crashes when I switch tabs.
I found something similar in Appolo Music, however I did not understand were the player strip is defined (full code is here: https://github.com/CyanogenMod/android_packages_apps_Apollo)
EDIT:
I found using the Hierarchy viewer that the extra layout gets deleted on runtime. This is interesting.

Creating an Android Nav Bar that replaces button with image when that activity is active

I am looking to create a Nav Bar in my Android application that functions very similar to the Nav Bar used by the Netflix app. There will be 4 buttons aligned horizontally. When one of those buttons is selected, the appropriate activity loads and that button is replaced by an image.
There are multiple ways I can achieve this, but since I am new to programming for Android, I figured I'd ask the community first. I list the first two that come to my head below.
Create a Linear Layout and define a separate layout for each activity. The Layout would include two more linear layouts, a horizontal linear layout for the nav bar and a vertical layout for the content.
Create a custom ui component named nav bar that extends a linear layout (based upon earlier threads I have seen about nav bars on here). Inflate that layout for each activity, then make a framelayout that overlays an image on top of the active button (the button that was just pressed). Then create onButtonClick listeners for each button except for the active button.
I'm not sure if there is a better way to achieve this and I am open to any suggestions. Any feedback would be great.
I'm not sure how the netflix app looks, but you might want to check out ye good olde tab-layout? ( http://developer.android.com/resources/tutorials/views/hello-tabwidget.html )
Also be sure to take a look at the android design page: http://developer.android.com/resources/tutorials/views/hello-tabwidget.html

Android creating Bottom Bar Menu

I want to have an static bottom menu bar exist through out the applications in every page visible at bottom all the time. I have designed the menu bar but i am confused whether i have to integrate the menu code with every layout xmls to make menu visible in every page and write the code in every activity class to perform functions on menu clicks. Or if there is any other way i can create a common bottom bar that lies with every page with writing the code of menu in a single activity class.
Well the best way in my opinion , is to create a bottom bar xml file , and include it in every Activity's xml file
<include android:layout_width="fill_parent" layout="#layout/bottom_bar" />
where your bottom bar xml file name is bottom_bar.xml
This article also might help you
http://android-developers.blogspot.com/2009/02/android-layout-tricks-2-reusing-layouts.html
There is also the include route:
Common layout in all tabs
What you are probably looking for is one Activity with a TabBar with tabs at the top and buttons at the bottom: Android: Tabs at the BOTTOM
Then you can use different Views that correspond to Tabs instead of separate Activities.

Categories

Resources