android spinner 简书,Android NiceSpinner

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

真的是简单又好用哦!有需要的小伙伴们可以试试啦。

效果图如下:

d0e6531c2162

image

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"/>

在 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 目录下)

android:width="1dip"

android:color="#52a2e2" />

android:bottomRightRadius="6dp"

android:topRightRadius="6dp"

android:bottomLeftRadius="6dp"

android:topLeftRadius="6dp"/>

有需要的拿走呦👉!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值