All Projects → weibeld → AndroidTabsExample

weibeld / AndroidTabsExample

Licence: other
An Example Android Application with Tabs

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to AndroidTabsExample

Bottomsheetcoordinatorlayout
A handy CoordinatorLayout that works well when used in a bottom sheet, even with AppBarLayouts inside.
Stars: ✭ 241 (+1317.65%)
Mutual labels:  android-ui
random-users-details
Random Users details in flutter from randomusers api
Stars: ✭ 14 (-17.65%)
Mutual labels:  android-ui
edge-to-edge-decorator
Edge to edge decorator - is a utility class that is responsible for coloring the statusBar and navigationBar to maintain edge to edge (e2e) mode.
Stars: ✭ 47 (+176.47%)
Mutual labels:  android-ui
Collapsingtoolbarlayout Subtitle
Standard CollapsingToolbarLayout with subtitle support
Stars: ✭ 244 (+1335.29%)
Mutual labels:  android-ui
awesome-android-libraries
😎 A curated list of awesome Android libraries
Stars: ✭ 135 (+694.12%)
Mutual labels:  android-ui
andColorPicker
Color picker library for Android
Stars: ✭ 233 (+1270.59%)
Mutual labels:  android-ui
Primer
Intro Animation like Google Primer
Stars: ✭ 230 (+1252.94%)
Mutual labels:  android-ui
XCPullToLoadMoreListView
XCPullToLoadMoreListView-下拉加载更多ListView控件(仿QQ、微信聊天对话列表控件)
Stars: ✭ 24 (+41.18%)
Mutual labels:  android-ui
android-cuberto-dialog-design
This is an implementation inspired by beautiful design by Cuberto on his Dribble page, which can be found here https://dribbble.com/shots/3206606-Landing-page-wip
Stars: ✭ 15 (-11.76%)
Mutual labels:  android-ui
PageStepIndicator
Step indicator with titles/labels and tons of customizations.
Stars: ✭ 27 (+58.82%)
Mutual labels:  android-ui
Aboutlibraries
AboutLibraries automatically detects all dependencies of a project and collects their information including the license. Optionally visualising it via the provided ui components.
Stars: ✭ 2,777 (+16235.29%)
Mutual labels:  android-ui
Circular-Layout
A layout that arranges other views in a circle.
Stars: ✭ 46 (+170.59%)
Mutual labels:  android-ui
QuestionnaireView
A simple view to be able to display question and various field (Radio, EditText, checkbox ) for answers
Stars: ✭ 34 (+100%)
Mutual labels:  android-ui
Awesome Android Complete Reference
Awesome Android references for everything like best practices, performance optimization, etc.
Stars: ✭ 2,701 (+15788.24%)
Mutual labels:  android-ui
SnappCompose
A clone of Snapp using Jetpack Compose. Showcasing various usages of Google Maps Animations etc combined with Compose
Stars: ✭ 59 (+247.06%)
Mutual labels:  android-ui
Pageindicator
An Instagram like page indicator compatible with RecyclerView and ViewPager.
Stars: ✭ 236 (+1288.24%)
Mutual labels:  android-ui
TypedTextView
Custom implementation of Android's TextView simulating a keyboard/type-writer.
Stars: ✭ 57 (+235.29%)
Mutual labels:  android-ui
github-commit-browser
A blog companion sample project that demonstrates saving UI state after process death on Android utilizing the community established 3rd party libraries
Stars: ✭ 55 (+223.53%)
Mutual labels:  android-ui
VideoPreLoading
Demo for video PreLoading/ PreCaching using ExoPlayer 2.13.3 in Android.
Stars: ✭ 61 (+258.82%)
Mutual labels:  android-ui
bottomsheets
Material Bottom Sheets library for Android
Stars: ✭ 76 (+347.06%)
Mutual labels:  android-ui

Android Tabs Example

Example app showing how to implement tabs in Android.

App Screenshot

Table of Contents

Usage

  1. Import project into Android Studio
  2. Switch to the desired Git branch
  3. Hit Run

Branches

Each branch contains a fully working configuration:

Basics

Typically, an implementation of tabs in Android consists of:

  1. Swipe views
  2. Tabs UI element

These are two independent navigation patterns, but they can be combined with each other.

In general: swipe views can (but don't need to) be combined with tabs, and tabs can (but don't need to) be combined with swipe views. However, tabs benefit tremendously from being combined with swipe views, as explained below.

Swipe Views

Swipe views allow to flip through a set of "pages" by swiping horizontally on the screen.

Combined with tabs, this allows the user to switch to the next or previous tab by just swiping anywhere on the screen, rather than having to click on the tab itself.

The swipe views architecture is illustrated below:

Swipe Views Architecture

See branches 01_swipe_views_and_actionbar and 04_swipe_views_and_toolbar for code examples.

References:

Tabs

There are currently two ways to implement a tabs UI element in Android:

  1. TabLayout tabs using TabLayout from the Design Support Library
  2. ActionBar tabs using the ActionBar's NAVIGATION_MODE_TABS feature (DEPRECATED)

TabLayout Tabs

This is the preferred approach as it's easier to implement than ActionBar tabs and does not rely on an ActionBar.

TabLayout tabs are especially easy to implement if they are used in combination with a formerly implemented ViewPager (see Swipe Views), because then the tabs can be automatically populated by the ViewPager (i.e. no need to create and add the individual tabs manually). This is shown in the following:

  1. In the activity's layout XML, add a TabLayout element above the ViewPager element (and below the Toolbar element, if a Toolbar is used)
  2. In the activity's onCreate method, call setupWithViewPager(ViewPager) on the TabLayout to populate and integrate the TabLayout with the ViewPager (requires that getPageTitle of the PagerAdapter is overriden)

Note: to use TabLayout, the Design Support Library must be added to the project. In the module build.gradle file, do:

dependencies {
    compile 'com.android.support:support-v13:24.2.1'
}

See branches 06_tablayout_tabs_fixed_and_toolbar and 07_tablayout_tabs_scrollable_and_toolbar for code examples.

References:

ActionBar Tabs

Note that this approach was DEPRECATED in API level 21.

This requires the usage of the old-fashioned ActionBar as the app bar (rather than the "modern" Toolbar).

To implement ActionBar tabs, the following steps are needed in the activity's onCreate method:

  1. Set ActionBar to tab mode by setNavigationMode(ActionBar.NAVIGATION_MODE_TABS)
  2. Implement an ActionBar.TabListener
  3. Create tabs as ActionBar.Tabs and add them to the ActionBar

If the tabs are used in combination with swipe views (see above), the tabs must be bidirectionally integrated with the ViewPager:

  1. In [onTabSelected](https://developer.android.com/reference/android/app/ActionBar.TabListener.html#onTabSelected(android.app.ActionBar.Tab, android.app.FragmentTransaction)) of the ActionBar.TabListener, update the current page of the ViewPager (setCurrentItem)
  2. Implement a ViewPager.SimpleOnPageChangeListener, and in its onPageSelected method update the current tab of the ActionBar (setSelectedNavigationItem)

This ensures that when the user clicks on a tab, the ViewPager switches to the corresponding page (1), and vice versa, when the user swipes to another page, the corresponding tab is selected in the ActionBar (2).

See branch 03_actionbar_tabs_DEPRECATED for code examples.

References:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].