This is a custom view to draw dotted, vertical lines.
Read more…All snippets tagged with android
Page 2 of 7A View that shows a vertical, dotted line
Various Square- or Fixed-ratio layouts and views
These are various snippets that can be used to create views that have a fixed ratio.
Read more…Progress bar masked by text
This custom view shows a progress bar in the foreground of a TextView. Check the Pixplicity Authenticator app for an example.
Read more…View with a hook to add draw operations
This view allows draw operations to be executed in a different class. This makes it easier to draw onto a canvas without having to create a custom view for every different use case.
Read more…GIF compatible EditText
The snippet below is a custom view that enables keyboard like GBoard to enter GIFs and stickers.
Read more…Pie chart-like progress bar
This custom view shows a clock-like circular countdown, and can be used as a timer or as a ProgressBar
. To use as a timer, create your own handler (or similar) to update the progress automatically.
Using <ul> in TextViews
Adds very basic support for using bulleted lists in TextViews
.
Underline text in a view
There’s no textStyle
to add underline to a TextView
or Button
. Use the following to add it programmatically instead:
All the adjustments to get a completely transparent statusbar
First, edit the themes. This is an example to use for your Activity in the default styles.xml
:
Take a screenshot of a view
These snippets allows grabbing a screenshot of a View
or Activity
as a bitmap.
There are special version to make this work on SurfaceView
s and TextureView
s.
Shrinkin/growing ViewPager
When iOS-ifying a ViewPager
, it is often needed to animate the pages when they come into view.
The following snippet shrinks the offscreen pages a little bit, and grows them to regular size when swiping them
to the center of the display.
Getting the screen size in pixels
Start by getting a reference to the WindowManager
. When in an Activity
, you can use getWindowManager()
, otherwise, use:
Bottom-to-top chat-style reversed RecyclerView
To turn a RecycerView
upside-down, and add elements from the bottom like a chat window, use this:
RecyclerView with CursorAdapter and reordering
This is a combination of a CursorAdapter
fit for RecyclerViews
, and several helpers to support drag-and-drop and swipe-to-dismiss.
Using a RecyclerView
This is the bare minimum boilerplate for quickly creating a RecyclerView.
Read more…