SpannableBar


Source link: https://github.com/GreaseMonk/SpannableBar


SpannableBar

Note: you need to use the gradle dependency, cloning the repository will probably not compile as it is a work in progress.

SpannableBar is a Grid-style spannable bar, that is useful when you need a way to span a bar over columns. The view allows you to set the starting column, the span, the number of columns, and more.

I have personally spent days to GridView, GridLayout and TableLayout but have been unable to SIMPLY make a 'bar' that spans over a couple of columns, with the possibility to set the start as well. Even if that would work, those views would be too over complicated with a lot of features I did not need.

I decided to create a custom view that does only what I needed it to be.

The following example usage is from the TimeTable repository Here you can see a timetable where SpannableBars are used in each row item.

Installation

Include the following in your build.gradle as a dependency:

dependencies {

compile 'com.github.greasemonk:spannablebar:1.0.2' 
}

If this fails, make sure to check if you have synchronized your local repositories.

In IntelliJ or Android Studio, you can find this under Settings>Build,Execution,Deployment>Build Tools>Maven>Repositories.

Usage

Include the layout in your XML:

<com.greasemonk.spannablebar.SpannableBar

 android:layout_width="match_parent"

 android:layout_height="48dp"

 android:id="@+id/bar"/>

Some optional XML properties include:

xmlns:app="http://schemas.android.com/apk/res-auto"  app:barText="my text" app:barTextColor="@android:color/white"

// Default is DEFAULT_TEXT_COLOR -> Color.WHITE app:barColor="@android:color/holo_blue_light"
// Default is DEFAULT_BAR_COLOR -> Color.LTGRAY

Set the bar's properties:

SpannableBar bar = (SpannableBar) findViewById(R.id.bar);
  // Sets all the properties in one go bar.setProperties(int start, int span, int columnCount);
  bar.setColumnCount(int numColumns);

// Default is SpannableBar.DEFAULT_COLUMN_COUNT -> 7 bar.setStart(int start);

  // Default is SpannableBar.DEFAULT_START -> 0 bar.setSpan(int span);

 // Default is SpannableBar.DEFAULT_SPAN -> 7  // Optionally set the corner radius (for all corners) bar.setRadius(float radius)

  // Default is 0  (this will be fixed later, should be SpannableBar.DEFAULT_RADIUS -> 8f  for 48dp bar.setColor(int color) bar.setTextAlignment(Paint.Align align) bar.setShowCellLines(boolean show) bar.setCellLineColor(int color) bar.setTextTypeface(Typeface typeface)  // Set the cell background color // Example:  bar.setColumnColor(0,Color.argb(48,0,0,0));
 will make it light gray. bar.setColumnColor(int row, int color)  

Resources

An adapter to create Android RecyclerViews with sections, providing headers and footers.

A library to make pretty badges.

Android Orientation Sensor Library helps you to get more accurate vector values of orientation, using all available device sensors.

Mortar Architect provides a flexible stack for navigating and displaying views and their presenters.

Architect is Mortar scope-centric. A Mortar scope is the glue between a View and its ViewPresenter. Architect will create a Mortar scope for each View & ViewPresenter association. A StackScope is a class that Architect will look for when building a Mortar scope, and its role is to configure the Mortar scope.

In your applications you often need to change certain configuration settings, monitor internal state or simply try to understand what, DebugDrawer allows you to easily add a slide out drawer with the ability to do this. Classes are provided to allow you to easily create your own additions to customize to your needs.

Android SharedPreferences wrapper and injector (based on Dart).

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