All Projects β†’ StephenVinouze β†’ Materialnumberpicker

StephenVinouze / Materialnumberpicker

Licence: apache-2.0
A customizable number picker based on Material guidelines

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to Materialnumberpicker

Pretty Swag
Pretty UI for Swagger spec
Stars: ✭ 112 (-6.67%)
Mutual labels:  material-design
Materialabout
It's a material-design about screen to use on your Android apps. A developer profile and application information easy to integrate. πŸ”–
Stars: ✭ 1,511 (+1159.17%)
Mutual labels:  material-design
Servicestackvs
ServiceStackVS - Visual Studio extension for ServiceStack
Stars: ✭ 117 (-2.5%)
Mutual labels:  material-design
Material Palette Generator
🎨 Get perfect Material Design color palettes from any hex color.
Stars: ✭ 114 (-5%)
Mutual labels:  material-design
Materialcomponent.banner
Material component for Android: Banner
Stars: ✭ 115 (-4.17%)
Mutual labels:  material-design
Flutter Movies4u
Movies4u app UI is simple enough to use and the app is a fun way to get an overview of your movie experience. This repo created with help of awesome UI, material Design and latest feature. this repo contain major feature like : dark theme.
Stars: ✭ 116 (-3.33%)
Mutual labels:  material-design
Smart Webcomponents
Web Components & Custom Elements for Professional Web Applications
Stars: ✭ 110 (-8.33%)
Mutual labels:  material-design
Flutter app sample
flutter app sample
Stars: ✭ 120 (+0%)
Mutual labels:  material-design
Material Upvote
Material Upvote Animationβ€Š Implementation of UI Concept by Jan Kuijken
Stars: ✭ 116 (-3.33%)
Mutual labels:  material-design
Brainphaser
Android Quiz App (Spaced Repetition) made with Material Design; features categories, statistics and different question modes
Stars: ✭ 117 (-2.5%)
Mutual labels:  material-design
Materialtextfield
A different beautiful Floating Edit Text
Stars: ✭ 1,504 (+1153.33%)
Mutual labels:  material-design
Teammate Android
A Team Management app for creating tournaments and games for various sports
Stars: ✭ 116 (-3.33%)
Mutual labels:  material-design
Vuetify Swipeout
πŸ‘† A swipe out example built with Vue CLI 3 + Vuetify + Swiper.
Stars: ✭ 117 (-2.5%)
Mutual labels:  material-design
Mdl Ext
Material Design Lite Ext: Components built with Google Material Design Lite framework. http://leifoolsen.github.io/mdl-ext/
Stars: ✭ 112 (-6.67%)
Mutual labels:  material-design
Vsc Material Theme
Material Theme, the most epic theme for Visual Studio Code
Stars: ✭ 1,617 (+1247.5%)
Mutual labels:  material-design
Voice
Minimalistic audiobook player
Stars: ✭ 1,559 (+1199.17%)
Mutual labels:  material-design
Folding Cell
πŸ“ƒ FoldingCell is an expanding content cell with animation made by @Ramotion
Stars: ✭ 10,035 (+8262.5%)
Mutual labels:  material-design
Angular5 Example Shopping App
Angular 5 Example Shopping App + Angular Material + Responsive
Stars: ✭ 120 (+0%)
Mutual labels:  material-design
Sscustomedittextoutlineborder
Same as an Outlined text fields presented in Material Design page but with some dynamic changes
Stars: ✭ 119 (-0.83%)
Mutual labels:  material-design
Mato
Mato - Icon pack for Linux
Stars: ✭ 117 (-2.5%)
Mutual labels:  material-design

MaterialNumberPicker

Release Build Status API Android Arsenal GitHub license

This library takes over the repository that I originally created and passed on but seems no longer maintained. It was ported in Kotlin to provide clearer and more optimized code, and includes various features that are still pending in the previous library. It also provides optionals and nullables with a custom constructor so that you can customize your picker the way you want without using a verbose builder pattern.

Native NumberPicker MaterialNumberPicker (default) MaterialNumberPicker (custom)
Default picker Simple picker Custom picker

Gradle Dependency

Add this in your root build.gradle file:

allprojects {
    repositories {
	maven { url "https://jitpack.io" }
    }
}

Then add the dependencies that you need in your project.

dependencies {
    compile "com.github.StephenVinouze:MaterialNumberPicker:{latest_version}"
}

Usage

Both XML and programmatic instanciations are supported :

<com.github.stephenvinouze.materialnumberpickercore.MaterialNumberPicker
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:mnpMaxValue="50"
    app:mnpMinValue="1"
    app:mnpEditable="false"
    app:mnpFontname="Hand.ttf"
    app:mnpSeparatorColor="@color/colorAccent"
    app:mnpTextColor="@color/colorPrimary"
    app:mnpTextSize="16sp"
    app:mnpTextStyle="bold"
    app:mnpValue="10"
    app:mnpWrapped="false" />
val numberPicker = MaterialNumberPicker(
    context = this,
    minValue = 1,
    maxValue = 50,
    value = 10,
    separatorColor = ContextCompat.getColor(this, R.color.colorAccent),
    textColor = ContextCompat.getColor(this, R.color.colorPrimary),
    textSize = resources.getDimensionPixelSize(R.dimen.numberpicker_textsize),
    textStyle = Typeface.BOLD_ITALIC,
    editable = false,
    wrapped = false,
    fontName = "Hand.ttf",
    formatter = NumberPicker.Formatter {
        return@Formatter "Value $it"
    }
)

For Java users, I have overloaded the constructor so that it generates all possible constructors.

MaterialNumberPicker numberPicker = new MaterialNumberPicker(
    this,
    1,
    50,
    10,
    ContextCompat.getColor(this, R.color.colorAccent),
    ContextCompat.getColor(this, R.color.colorPrimary),
    getResources().getDimensionPixelSize(R.dimen.numberpicker_textsize),
    Typeface.BOLD_ITALIC,
    false,
    false,
    "Hand.ttf",
    new NumberPicker.Formatter() {
        @Override
        public String format(int i) {
            return "Value " + i;
        }
    }
);

I have arranged the parameters in priority order but it is not as ideal as with Koltin because you can't name the attributes nor change their orders. However, all attributes are exposed with getter/setters so you can easily set the desired attributes after instanciating the picker with the default constructor.

MaterialNumberPicker numberPicker = new MaterialNumberPicker(this);
numberPicker.setTextColor(ContextCompat.getColor(this, R.color.colorPrimary));

Once you have your number picker, you can present it by itself, or within an alert dialog :

AlertDialog.Builder(this)
    .setTitle(title)
    .setView(numberPicker)
    .setNegativeButton(getString(android.R.string.cancel), null)
    .setPositiveButton(getString(android.R.string.ok), { _, _ ->
        Toast.makeText(this, getString(R.string.picker_value, numberPicker.value), Toast.LENGTH_LONG).show()
    })
    .show()

The only attribute that cannot be defined through XML is the formatter that is natively included in the NumberPicker. It can be directly assigned from the custom constructor when instanciating programmaticaly. Note that all attributes have their own getter/setters and can be upcated anytime durnig your view's lifecycle.

We also provide a way to define either your text style within the picker or a custom font. Be aware though that once you define a custom font, the text style will be overriden by the custom font and won't be interpreted.

Pull requests

I welcome and encourage all pull requests. I might not be able to respond as fast as I would want to but I endeavor to be as responsive as possible.

All PR must:

  1. Be written in Kotlin
  2. Maintain code style
  3. Indicate whether it is a enhancement, bug fix or anything else
  4. Provide a clear description of what your PR brings
  5. Enjoy coding in Kotlin :)
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].