Posts

#SnackBar gist: A ColoredSnackBar

Image
The default backgroud color for the snackbar in material design can be quite neutral. Of course it provides a lightweight feedback for the users. In same cases this kind of feedback, can to be too anonymous , and the user doesn't give it the right importance and attention . We are trying to use (not everywhere and not always) a colored snackbar, to highlight the type of message that we are showing. In this way the user can recognize a warning message for example. Ok... it is not material (or not?)... but the feedback from users is very good. And yes.. it remembers the styles used by Crouton. Here a simple gist .

A Material styled AlertDialog

Image
Are you looking for a Material styled AlertDialog? Here a short gist to migrate the "old" AlertDialog AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("Dialog"); builder.setMessage("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo,"); builder.setPositiveButton("OK", null); builder.setNegativeButton("Cancel", null); builder.show(); Now you can use the new android.support.v7.app.AlertDialog and the the code becomes: import android.support.v7.app.AlertDialog; AlertDialog.Builder builder = new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle); builder.setTitle("Dialog")...

Android #gist: A SectionedGridRecyclerViewAdapter

Image
It is a SectionedGridRecyclerViewAdapter . It is the porting of the SimpleSectionedListAdapter[1] provided by Google with the #io code. It can be used to realize a simple sectioned grid without changing your adapter. It works with a RecyclerView with a GridLayoutManager. Here the code : [1]: Google Io14

Android-5: Card and images with rounded corners in Android 4

Card and images with rounded corners in Android 4 As you know the CardView in support library has a different behaviour for API=21 and API &lt 21. If you would like to have an image (full or partial) inside your cardView with Rounded corners it is by default only in Android 5. This gist can be useful to achieve the same aspect also in Android V4 (and as always it can be improved) Here the link . The trick is to elaborate the image and obtain an image with rounded corners (I am using the snippet published by +Romain Guy) Pay attention: you have to use cardView.setPreventCornerOverlap(false) ; to avoid the internal padding in api&lt21.

Android-5 tip about the Toolbar and the Style

Toolbar style and theme. With the new Toolbar you can apply a style and a theme . They are different! The style is local to the Toolbar view, for example the background color. The app:theme is instead global to all ui elements inflated in the Toolbar, for example the color of the title and icons.

Android-L #gist4: a SimpleSectionedRecyclerView

Image
It is a SimpleSectionedRecyclerViewAdapter . It is the porting of the SimpleSectionedListAdapter[1] provided by Google with the #io code. It can be used to realize a simple sectioned list without changing your adapter. It works with a RecyclerView with a LinearLayoutManager and also work with the TwoWayView with the ListLayoutManager. Here the code : ps: the RecyclerView pattern is new... then this code can be improved (I am sure). [1]: Google Io14

Android-L gist#3 : Recycler View: Item Animations

Image
Here you can find a little collection of ItemAnimators for the RecyclerView . SlideInOutLeftItemAnimator : which applies a slide in/out from/to the left animation SlideInOutRightItemAnimator : which applies a slide in/out from/to the right animation SlideInOutTopItemAnimator : which applies a slide in/out from/to the top animation Github repo: https://github.com/gabrielemariotti/RecyclerViewItemAnimators