Android DSelectorBryant 单选滚动选择器的实例代码
单选滚动选择器、diy丰富、有阻尼效果、简单美观、触摸or点击模式 (Rolling Selector, Diy Rich, Damping Effect, Simple and Beautiful, Touch or Click Mode)
Github地址
YangsBryant/DSelectorBryant
(Github排版比较好,建议进入这里查看详情,如果觉得好,点个star吧!)
引入module allprojects { repositories { google() jcenter() maven { url 'https://www.jitpack.io' } } } implementation 'com.github.YangsBryant:DSelectorBryant:1.0.2'
主要代码
public class MainActivity extends AppCompatActivity { DSelectorPopup dSelectorPopup; ConstraintLayout constraintLayout; ArrayList<String> list = new ArrayList<>(); Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); for (int i = 0; i <= 10; i++) { list.add("YMF"+i); } dSelectorPopup = new DSelectorPopup(this,list); dSelectorPopup.build(); constraintLayout = findViewById(R.id.main); button = findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //弹出窗体 dSelectorPopup.popOutShadow(constraintLayout); } }); /*点击监听器 Tips:实现此监听器,点击button也会返回当前选中项的下标和文本,因此button既可以当做取消用,也可以当做确定用*/ dSelectorPopup.setSelectorListener(new DSelectorPopup.SelectorClickListener() { @Override public void onSelectorClick(int position, String text) { Toast.makeText(MainActivity.this,text,Toast.LENGTH_SHORT).show(); //缩回窗体 dSelectorPopup.dismissPopup(); } }); //滑动监听器 /*dSelectorPopup.setSelectoMoverListener(new DSelectorPopup.SelectorMoveListener() { @Override public void onSelectorMove(int position, String text) { Toast.makeText(MainActivity.this,text,Toast.LENGTH_SHORT).show(); } });*/ } }
参数实例
dSelectorPopup.setOffset(5) .setTextSize(30) .setTextcolor_selection(getResources().getColor(R.color.colorAccent)) .setTextcolor_unchecked(getResources().getColor(R.color.colorPrimary)) .setGradual_color(0xffD81B60) .setTitleText("我是标题") .setTitleColor(getResources().getColor(R.color.colorPrimary)) .setTitleSize(25) .setButton_background(getResources().getDrawable(R.drawable.popup_bg)).build();
Tips:分割线的颜色值为:0xff 加上16进制颜色值,例如:0xffD81B60
DSelectorBryant属性大全
总结
以上所述是小编给大家介绍的Android DSelectorBryant 单选滚动选择器的实例代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对海外IDC网网站的支持!如果你觉得本文对你有帮助,欢迎转载,烦请注明出处,谢谢!