SmartMaterialSpinner

SmartMaterialSpinner

功能丰富的Android自定义Spinner组件

SmartMaterialSpinner是一款功能丰富的Android Spinner库,提供下拉、对话框和可搜索等多种模式。该库支持浮动标签、错误提示和RTL布局,并可自定义颜色、字体和大小。SmartMaterialSpinner易于集成,能满足从简单到复杂的各种下拉选择需求,有助于提升Android应用的用户体验。

SmartMaterialSpinnerAndroid下拉菜单自定义视图用户界面Github开源项目

SmartMaterialSpinner

current License

The best Android spinner library for your android application with more customization

Available on Play Store

<a href="https://play.google.com/store/apps/details?id=com.chivorn.smsp.demojava" target="_blank"> <img src="https://github.com/Chivorns/Resources/blob/master/google-play-badge.png" alt="Play Store" width="140" "> </a>

Available features

Spinner mode

Dropdown ModeDialog ModeSearchable Mode
<img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_dropdown.gif" width="250" ><img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_dialog.gif" width="250" ><img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_searchable.gif" width="250" >
  • Dropdown mode ( android:spinnerMode="dropdown" ). By default it is dropdown mode
  • Dialog mode ( android:spinnerMode="dialog" )
  • Searchable mode ( app:smsp_isSearchable="true" )

Outlined Style

<img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_outlined.gif" width="250" >

Searchable spinner

  • smsp_isSearchable : Default is false. Set it to true to enable this feature.
  • smsp_enableSearchHeader: Default is true. Set it to false to hide search header.
  • smsp_searchHeaderText: Text display as header text
  • smsp_searchHeaderTextColor: For changing header text color
  • smsp_searchHeaderBackgroundColor: For changing header background color
  • smsp_searchHint: To set query text hint
  • smsp_searchHintColor: To set hint color to query search text
  • smsp_searchTextColor: To set color to query search text
  • smsp_searchBackgroundColor: To set background color to searchview
  • smsp_itemListBackgroundColor: To set background color to search item list
  • smsp_enableDismissSearch: To enable/disable dismiss button on search dialog
  • smsp_dismissSearchText: To set dismiss button text for search dialog
  • smsp_dismissSearchColor: To set dismiss button text color for search dialog
  • smsp_searchDropdownView: To custom search view item

Spinner item

  • smsp_itemSize: To set spinner item size
  • smsp_itemColor: To set spinner item color

Hint Label

  • smsp_hint: To set spinner hint text
  • smsp_hintSize: To set spinner hint text size
  • smsp_hintColor: To set spinner hint color
  • smsp_itemListHintColor: To set spinner hint text color (dropdown hint)
  • smsp_itemListHintBackgroundColor: To set spinner hint background (dropdown hint)

Floating Label

  • smsp_enableFloatingLabel: Default is true. Set it to false to disable floating label.
  • smsp_alwaysShowFloatingLabel: Default is false. Set it to true for always display.
  • smsp_floatingLabelText: Update it to what text you want. If the value is not set, it get from hint.
  • smsp_floatingLabelSize: For changing floating label size
  • smsp_floatingLabelColor: For changing floating label color

Error Label

  • smsp_enableErrorLabel: Default it is true.
  • smsp_errorText: Your error message text.
  • smsp_errorTextSize: For changing error text size
  • smsp_errorTextColor: for changing error text color
  • smsp_multilineError: Default is false. Update it to show as single line or multiple line
  • smsp_errorTextAlignment: Align error text to left, center or right

Color customization to:

  • Item text color (smsp_itemColor)
  • Hint color (smsp_hintColor)
  • Floating Label color (smsp_floatingLabelColor)
  • Error Text color (smsp_errorTextColor)
  • List Item Hint color and background (smsp_itemListHintColor & smsp_itemListHintBackgroundColor)
  • List Item color (smsp_itemListColor)
  • Selected item color (smsp_selectedItemListColor)
  • Arrow or selector color (smsp_arrowColor)
  • Underline color (smsp_underlineColor)
  • Dropdown list/Search ListView background (smsp_itemListBackgroundColor)
  • Search dialog dismiss button color (smsp_dismissSearchColor)

Empty dropdown clickable

  • In case if you want to design view with empty spinner and apply click event and here it is.

Underline

  • smsp_underlineSize: To set underline size (The bottom line of spinner)
  • smsp_underlineColor: To set underline color (The bottom line of spinner)

Re-selectable feature

  • smsp_isReSelectable: Allow re-selectable for current selected item. By default it is false

RTL (Right To Left) feature

  • smsp_isRtl: To change position of view from right to left or left to right. I will update more on it.

Typeface (Custom font)

  • smsp_typeface: Apply custom font to whole spinner view. You can use this attr without specify font extension
  • smsp_typeface_xxx: Set typeface to specific part of spinner

Screenshot Demo

<table border="0"> <tr> <td> <a target="_blank"> <img src="https://github.com/Chivorns/Resources/blob/master/smsp/smsp_home.jpg" alt="SmartMaterialSpinner" width="250" > </a> </td> </table>

Usage

Add the dependencies to your gradle file:

dependencies { implementation 'com.github.chivorns:smartmaterialspinner:2.0.0' }

Add SmartMaterialSpinner to your layout:

<com.chivorn.smartmaterialspinner.SmartMaterialSpinner android:id="@+id/spinner1" android:layout_width="match_parent" android:layout_height="wrap_content" app:smsp_errorText="This is error text. You can show it as single line or multiple lines using attr smsp_multilineError" app:smsp_floatingLabelColor="#1976D2" app:smsp_floatingLabelText="Floating Label Text" app:smsp_hint="Hint Text" app:smsp_hintColor="#388E3C" app:smsp_itemColor="#512DA8" app:smsp_itemListColor="#7C4DFF" app:smsp_itemListHintBackgroundColor="#808080" app:smsp_itemListHintColor="#FFFFFF" app:smsp_multilineError="false" app:smsp_selectedItemListColor="#FF5252" />

In Java class

import android.os.Bundle; import android.view.View; import android.widget.AdapterView; import android.widget.Toast; import androidx.appcompat.app.AppCompatActivity; import com.chivorn.smartmaterialspinner.SmartMaterialSpinner; import java.util.ArrayList; import java.util.List; public class MainActivity extends AppCompatActivity { private SmartMaterialSpinner<String> spProvince; private SmartMaterialSpinner<String> spEmptyItem; private List<String> provinceList; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.smart_material_spinner_sample_layout); initSpinner(); } private void initSpinner() { spProvince = findViewById(R.id.sp_provinces); spEmptyItem = findViewById(R.id.sp_empty_item); provinceList = new ArrayList<>(); provinceList.add("Kampong Thom"); provinceList.add("Kampong Cham"); provinceList.add("Kampong Chhnang"); provinceList.add("Phnom Penh"); provinceList.add("Kandal"); provinceList.add("Kampot"); spProvince.setItem(provinceList); spProvince.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) { Toast.makeText(MainActivity.this, provinceList.get(position), Toast.LENGTH_SHORT).show(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); } }

In Kotlin class

import android.os.Bundle import android.view.View import android.widget.AdapterView import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.chivorn.resourcemodule.R import com.chivorn.smartmaterialspinner.SmartMaterialSpinner class MainActivity : AppCompatActivity() { private var spProvince: SmartMaterialSpinner<String>? = null private var spEmptyItem: SmartMaterialSpinner<String>? = null private var provinceList: MutableList<String>? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.smart_material_spinner_sample_layout) initSpinner() } private fun initSpinner() { spProvince = findViewById(R.id.sp_provinces) spEmptyItem = findViewById(R.id.sp_empty_item) provinceList = ArrayList() provinceList?.add("Kampong Thom") provinceList?.add("Kampong Cham") provinceList?.add("Kampong Chhnang") provinceList?.add("Phnom Penh") provinceList?.add("Kandal") provinceList?.add("Kampot") spProvince?.item = provinceList spProvince?.onItemSelectedListener = object : AdapterView.OnItemSelectedListener { override fun onItemSelected(adapterView: AdapterView<*>, view: View, position: Int, id: Long) { Toast.makeText(this@MainActivity, provinceList!![position], Toast.LENGTH_SHORT).show() } override fun onNothingSelected(adapterView: AdapterView<*>) {} } } }

Issue and new feature request

Note

Each raised issue, should be provided with some information to be easy for me to replicate it like Device Model, Android version and log message or file

Where to report issue and new feature request

You can create issue on Github to record issue history then to make it fast alert to me, you can send me email or post to Facebook group for any discussion

Contribution

If you want to contribute in this library, please fork this repository and create pull request.

Contributors

<a href="https://github.com/Chivorns/SmartMaterialSpinner/graphs/contributors"> <img src="https://contrib.rocks/image?repo=Chivorns/SmartMaterialSpinner" /> </a>

Made with contributors-img.

License

   Copyright [2018] [Chivorn]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

编辑推荐精选

Vora

Vora

免费创建高清无水印Sora视频

Vora是一个免费创建高清无水印Sora视频的AI工具

Refly.AI

Refly.AI

最适合小白的AI自动化工作流平台

无需编码,轻松生成可复用、可变现的AI自动化工作流

酷表ChatExcel

酷表ChatExcel

大模型驱动的Excel数据处理工具

基于大模型交互的表格处理系统,允许用户通过对话方式完成数据整理和可视化分析。系统采用机器学习算法解析用户指令,自动执行排序、公式计算和数据透视等操作,支持多种文件格式导入导出。数据处理响应速度保持在0.8秒以内,支持超过100万行数据的即时分析。

AI工具使用教程AI营销产品酷表ChatExcelAI智能客服
TRAE编程

TRAE编程

AI辅助编程,代码自动修复

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

热门AI工具生产力协作转型TraeAI IDE
AIWritePaper论文写作

AIWritePaper论文写作

AI论文写作指导平台

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

数据安全AI助手热门AI工具AI辅助写作AI论文工具论文写作智能生成大纲
博思AIPPT

博思AIPPT

AI一键生成PPT,就用博思AIPPT!

博思AIPPT,新一代的AI生成PPT平台,支持智能生成PPT、AI美化PPT、文本&链接生成PPT、导入Word/PDF/Markdown文档生成PPT等,内置海量精美PPT模板,涵盖商务、教育、科技等不同风格,同时针对每个页面提供多种版式,一键自适应切换,完美适配各种办公场景。

热门AI工具AI办公办公工具智能排版AI生成PPT博思AIPPT海量精品模板AI创作
潮际好麦

潮际好麦

AI赋能电商视觉革命,一站式智能商拍平台

潮际好麦深耕服装行业,是国内AI试衣效果最好的软件。使用先进AIGC能力为电商卖家批量提供优质的、低成本的商拍图。合作品牌有Shein、Lazada、安踏、百丽等65个国内外头部品牌,以及国内10万+淘宝、天猫、京东等主流平台的品牌商家,为卖家节省将近85%的出图成本,提升约3倍出图效率,让品牌能够快速上架。

iTerms

iTerms

企业专属的AI法律顾问

iTerms是法大大集团旗下法律子品牌,基于最先进的大语言模型(LLM)、专业的法律知识库和强大的智能体架构,帮助企业扫清合规障碍,筑牢风控防线,成为您企业专属的AI法律顾问。

SimilarWeb流量提升

SimilarWeb流量提升

稳定高效的流量提升解决方案,助力品牌曝光

稳定高效的流量提升解决方案,助力品牌曝光

Sora2视频免费生成

Sora2视频免费生成

最新版Sora2模型免费使用,一键生成无水印视频

最新版Sora2模型免费使用,一键生成无水印视频

下拉加载更多