031 Android 第三方开源下拉框:NiceSpinner的使用

1.NiceSpinner下拉框控件介绍

Android原生的下拉框Spinner基本上可以满足Android开发对于下拉选项的设计需求,但现在越来越流行的下拉框不满足于Android原生提供的下拉框Spinner所提供的设计样式,而改用自定制或者第三方设计的下拉框Spinner。NiceSpinner是一个第三方开源的下拉框Spinner。

2.使用步骤

(1)build.gradle(project)中一段代码替换为如下内容:(android studio工程的标配)

buildscript {
    
    repositories {
        google()
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.0'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven{url 'http://maven.aliyun.com/nexus/content/groups/public/'}
        google()
        maven { url "https://jitpack.io" }
    }
}

(2)build.gradle(app)中添加依赖

dependencies {
    implementation 'com.github.arcadefire:nice-spinner:1.4'
}

3.NiceSpinner下拉框控件的属性分析

You can add attributes to customize the view. Available attributes:

用户可以在xml文件布局中添加以下表格中的属性到NiceSpinner控件中,对NiceSpinner进行设置。

name type info
arrowTint color sets the color on the drop-down arrow
hideArrow boolean set whether show or hide the drop-down arrow
arrowDrawable reference set the drawable of the drop-down arrow
textTint color set the text color
dropDownListPaddingBottom dimension 设置下拉列表的底部填充
backgroundSelector integer set the background selector for the drop-down list rows
popupTextAlignment enum set the horizontal alignment of the default popup text
entries reference set the data source from an array of strings

猜你喜欢

转载自www.cnblogs.com/luckyplj/p/10876418.html
今日推荐