Example code of Android dselector Bryant radio scroll selector
Rolling selector, DIY rich, damping effect, simple and beautiful, touch or click mode
GitHub address
YangsBryant/DSelectorBryant
(GitHub has a good layout. It is recommended to check the details here. If you feel good, click star!)
引入module allprojects { repositories { google() jcenter() maven { url 'https://www.jitpack.io' } } } implementation 'com.github.YangsBryant:@R_929_419@:1.0.2'
Main code
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,Toast.LENGTH_SHORT).show(); } });*/ } }
Parameter instance
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: the color value of the split line is: 0xff plus hexadecimal color value, for example: 0xffd81b60
@R_ 929_ 419 @ complete collection of attributes
summary
The above is Android @ r introduced by Xiaobian_ 929_ 419 @ example code of radio scroll selector. I hope it will help you. If you have any questions, please leave me a message, and Xiaobian will reply to you in time. Thank you very much for your support to our website! If you think this article is helpful to you, welcome to reprint, please indicate the source, thank you!