BadgedTabLayout


Source link: https://github.com/rahimlis/badgedtablayout

BadgedTabLayout

Did you see those small badges indicating new messages count in WhatsApp near your chats? You can achieve the same result using this library. It is created to add small circled badges in tab layout.

Screen

Installation

allprojects {
  repositories {

 ...
 maven {
 url 'https://jitpack.io' 
}

}
 
}
dependencies {

compile 'com.github.rahimlis:badgedtablayout:v1.1' 
}

Usage

Add BadgedTabLayout as if you added TabLayout itself

<android.support.design.widget.AppBarLayout ...>

<android.support.v7.widget.Toolbar ... />

  <com.rahimlis.badgedtablayout.BadgedTabLayout

  android:id="@+id/tabs"

  android:layout_width="match_parent"

  android:layout_height="wrap_content"

  app:badgeBackgroundColor="@color/badge_background_color"

  />
 </android.support.design.widget.AppBarLayout>

then in java do:

BadgedTabLayout tabLayout = (BadgedTabLayout) findViewById(R.id.tabs);
 tabLayout.setupWithViewPager(mViewPager);

to set text of the badge use:

  //first parameter is the tab index, at which badge should appear
tabLayout.setBadgeText(1,"1");

//if you want to hide a badge pass null as a second parameter
tablayout.setBadgeText(0,null);

to set icon to the tab use:

tabLayout.setIcon(0, R.drawable.ic_favorite);
 // 0 is the position of tab where icon should be added tabLayout.setIcon(1, R.drawable.ic_shopping);

Note: by default badges are hidden. You need to set some text to show it up.

Customization

you can customize tab text colors and size as if you would do it for tabLayout

app:tabTextColor="@color/your_unselected_text_color" app:tabSelectedTextColor="@color/your_selected_text_color" app:tabTextSize="11sp"

additionally you can change badge background color, as well as badge text color and text size

app:badgeTextColor="@color/your_selected_color" app:badgeSelectedTextColor="@color/your_selected_color" app:badgeBackgroundColor="@color/your_selected_color" app:badgeSelectedBackgroundColor="@color/your_selected_color" app:badgeTextSize="11sp"

another way to do this is to create color state list and pass it to corresponding field:

<!-- file badge_background_color.xml / badge_text_color.xml at color directory --> <selector xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:color="#ff0" android:state_selected="true" />
  <item android:color="#f0f" android:state_selected="false" /> </selector>

then:

app:badgeBackgroundColor="@color/badge_background_color" app:badgeTextColor="@color/badge_text_color"

you also can change every property programmatically, look at class documentation for more information.

Contribution

Feel free to make pull requests and open issues if you meet any.
Please add your app name if you use this library in the issues. I will add your app into the list.

Resources

Easy RecyclerView ItemDecoration. Flexible for multiple styles, such as margins, colours, drawables, show/hide, etc.

There is a bunch of useful widgets and navigation classes to make your app clear and simpler. Include features like font from asses via xml, complex background, resizable compound drawables, FlowLayout and SlideMenuLayout (expand menu from any direction), custom backstack (abstract + fragments impl).

Android EditText wrapper to support text / emoji / camera / media input.

Features

  • advance overrides to enable custom behaviour/look
  • built in media picker
    • camera capture for quick pics
    • photo/file selector
  • gif keyboard entry support
  • file/attachment preview
  • multi-file support

This Layout provide fling dismiss effect like Twitter ImageView

A custom layout that fills given width or height as per the original ratio of each child.

If given width or height is exceeded, it largely replicates the behavior of LinearLayout.

What RatioFillLayout offers:

  • Orientation: horizontal, vertical
  • Gravity: top, bottom, left, right, centerhorizontal, centervertical

What is iSortBox? Just like what it says: Simplify sorting!

This framework achieves a goal which makes sorting easier, moreover, you will benefit from what it provides such as pre-processing, converting, grouping and filtering.

As the name iSortBox, the letter 'i' means input and the letter 'o' means output, as for the details on how to complete the work, all are encapsulated in iSortBox.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes