NiceSpinner 是 Android 端的一款第三方控件,自带箭头动画效果

GitHub地址

效果图如下:



目录

1. 导入模块

2. 代码测试



1. 导入模块

在 Github 下载并导入模块

或者在 build.gradle 中修改:

allprojects {    repositories {        ...        maven { url "https://jitpack.io" }    }}dependencies {    compile 'com.github.arcadefire:nice-spinner:1.3.1'}

建议导入模块,可以修改。



2. 代码测试

在 activity_main.xml 文件中加入:

    android:id="@+id/nice_spinner"    android:layout_width="0dp"    android:layout_height="match_parent"    android:layout_weight="1"    app:arrowTint="@color/light_gray"    app:textTint="@color/myBlack"    app:dropDownListPaddingBottom="60dp"    android:layout_marginEnd="12dp"    android:layout_marginRight="12dp"/>
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 set the bottom padding of the drop-down list
backgroundSelector integer set the background selector for the drop-down list rows

在 MainActivity.java 中加入:

private NiceSpinner niceSpinner;List spinnerData = new LinkedList<>(Arrays.asList("一月", "二月", "三月", "四月",        "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"));
niceSpinner = findViewById(R.id.nice_spinner);
    
niceSpinner.attachDataSource(spinnerData);niceSpinner.setBackgroundResource(R.drawable.textview_round_border);niceSpinner.setTextColor(Color.WHITE);niceSpinner.setTextSize(13)
niceSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {    @Override    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {            }    @Override    public void onNothingSelected(AdapterView<?> parent) {}})


textview_round_border.xml (设置圆角等属性,放在 drawable 目录下)

<?xml version="1.0" encoding="utf-8"?>xmlns:android="http://schemas.android.com/apk/res/android" >        android:color="#52a2e2" />                android:width="1dip"        android:color="#52a2e2" />                android:bottomRightRadius="6dp"        android:topRightRadius="6dp"        android:bottomLeftRadius="6dp"        android:topLeftRadius="6dp"/>


在 nice-spinner-master/src/main/java/NiceSpinner 目录下可以修改属性


更多相关文章

  1. Android(安卓)SDK下载和更新失败的解决方法
  2. Android(安卓)导入项目时遇到的JNI和NDK问题
  3. untiy导出android遇到的问题:convert error
  4. (一百三十八)学习Android(安卓)studio 导入Android源码
  5. Android(安卓)studio出现Error:Plugin is too old, please updat
  6. android下拉刷新android-Ultra-Pull-To-Refresh使用
  7. android 开机动画修改以及默认壁纸
  8. Android(安卓)无线启动过程分析 无线启动过程分析
  9. android里在程序中修改listView里的内容

随机推荐

  1. android双击返回键退出程序
  2. Android(安卓)OkHttp3 上传多张图片
  3. 原YUV格式的解析 Android(安卓)NV21 视频
  4. Android之开发杂记(一)
  5. android ui事件分析
  6. Android(安卓)监听短信接收 获取发件号码
  7. 学习Android之setDataAndType(利用第三方
  8. Android(安卓)DownloadManager 的使用
  9. Android(安卓)Studio
  10. Android开发 - 丰富常用的颜色文件colors