android自定义spinner,使用AppCompatTextView+PopupWindow 实现下拉选择的功能

为君一笑 提交于 2019-12-07 19:29:27

自定义spinner

自定义spinner,使用AppCompatTextView+PopupWindow 实现下拉选择的功能,代码简单,几个类

感谢

https://github.com/arcadefire/nice-spinner,本项目是对其的优化与扩展

1、实现了下拉菜单与现实view样式的分离,可单独对显示结果的textview进行样式的处理

2、对下拉菜单增加了分割线等等

……

效果图

apk下载链接: https://github.com/supertaohaili/spinner/blob/master/app-debug.apk

github:https://github.com/supertaohaili/Spinner

使用

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

dependencies {
          compile 'com.github.supertaohaili:Spinner:1.0.0'
}


示例代码:
<org.angmarch.views.NiceSpinner
     android:id="@+id/spinner2"
     android:layout_width="200dp"
     android:layout_height="40dp"
     android:layout_gravity="center_horizontal"
     android:layout_marginTop="25dp"
     android:background="@drawable/shape"
     android:gravity="center"
     app:dropDownListPaddingBottom="35dp" />


     NiceSpinner niceSpinner2 = (NiceSpinner) findViewById(R.id.spinner2);
     List<String> dataset2 = new LinkedList<>(Arrays.asList("10","11","12","13","14","15","16","17","18","19"));
     niceSpinner2.attachDataSource(dataset2);

Known Issues

If you have any questions/queries/Bugs/Hugs please mail @ taohailili@gmail.com

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!