欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android DSelectorBryant 單選滾動選擇器的實例代碼

 更新時間:2019年10月11日 13:55:21   作者:YangBryant  
本文通過實例代碼給大家介紹了Android DSelectorBryant 單選滾動選擇器的相關(guān)知識,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下

單選滾動選擇器、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);
  }
 });
 /*點擊監(jiān)聽器
 Tips:實現(xiàn)此監(jiān)聽器,點擊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();
  }
 });
 //滑動監(jiān)聽器
 /*dSelectorPopup.setSelectoMoverListener(new DSelectorPopup.SelectorMoveListener() {
  @Override
  public void onSelectorMove(int position, String text) {
  Toast.makeText(MainActivity.this,text,Toast.LENGTH_SHORT).show();
  }
 });*/
 }
}

參數(shù)實例

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屬性大全

方法名 屬性
build() 參數(shù)設置完畢,在最后build一下
setHeights(int height) PopupWindow的高度,單位dp
isOutside(boolean bl) 點擊彈窗外是否消失,默認true
setSeletion(int offset) 對話框中當前項上面和下面的項數(shù)
setOffset(int seletion) 默認選中項
setTextSize(int size) 文本字體大小
setTextcolor_selection(int textcolor_selection) 選中文本顏色
setTextcolor_unchecked(int textcolor_unchecked) 未選中文本顏色
setGradual_color(int gradual_color) 分割線顏色
setFining(boolean fining) 是否開啟分割線兩端變細,默認true
setTitleText(String titleText) 標題的文字
setTitleSize(int titleSize) 標題文字大小
setTitleColor(int titleColor) 標題文字顏色
setButtonText(String buttonText) 按鈕文本
setButtonSize(int buttonSize) 按鈕文字大小
setButtonColor(int buttonColor) 按鈕文字顏色
setButton_background(Drawable drawable) 按鈕背景
setButtonWidt(int buttonWidt) 按鈕寬度,單位dp
setButtonHeight(int buttonHeight) 按鈕高度,單位dp
popOutShadow(View view) 顯示彈窗
dismissPopup() 關(guān)閉彈窗
setSelectorListener(SelectorClickListener selectorListener) 點擊監(jiān)聽器
setSelectoMoverListener(SelectorMoveListener selectoMoverListener) 滑動監(jiān)聽器

總結(jié)

以上所述是小編給大家介紹的Android DSelectorBryant 單選滾動選擇器的實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對腳本之家網(wǎng)站的支持!如果你覺得本文對你有幫助,歡迎轉(zhuǎn)載,煩請注明出處,謝謝!

相關(guān)文章

最新評論