我正在嘗試制作一個像圖片中一樣的 TimePicker 串列。有人能幫我嗎

uj5u.com熱心網友回復:
簽出這個庫,它做了完全相同的事情。
uj5u.com熱心網友回復:
嘗試借助Github 中的這個庫進行自定義。
將此添加到您的 xml 檔案中
<com.shawnlin.numberpicker.NumberPicker
android:id="@ id/number_picker"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
app:np_width="64dp"
app:np_height="180dp"
app:np_dividerColor="@color/colorPrimary"
app:np_formatter="@string/number_picker_formatter"
app:np_max="59"
app:np_min="0"
app:np_selectedTextColor="@color/colorPrimary"
app:np_selectedTextSize="@dimen/selected_text_size"
app:np_textColor="@color/colorPrimary"
app:np_textSize="@dimen/text_size"
app:np_typeface="@string/roboto_light"
app:np_value="3" />
將此添加到您的班級
NumberPicker numberPicker = (NumberPicker) findViewById(R.id.number_picker);
// set divider color
numberPicker.setDividerColor(ContextCompat.getColor(this, R.color.colorPrimary));
numberPicker.setDividerColorResource(R.color.colorPrimary);
// set formatter
numberPicker.setFormatter(getString(R.string.number_picker_formatter));
numberPicker.setFormatter(R.string.number_picker_formatter);
// set selected text color
numberPicker.setSelectedTextColor(ContextCompat.getColor(this, R.color.colorPrimary));
numberPicker.setSelectedTextColorResource(R.color.colorPrimary);
// set text color
numberPicker.setTextColor(ContextCompat.getColor(this, R.color.dark_grey));
numberPicker.setTextColorResource(R.color.dark_grey);
// set text size
numberPicker.setTextSize(getResources().getDimension(R.dimen.text_size));
numberPicker.setTextSize(R.dimen.text_size);
// set selected text size
numberPicker.setSelectedTextSize(getResources().getDimension(R.dimen.selected_text_size));
numberPicker.setSelectedTextSize(R.dimen.selected_text_size);
// set typeface
numberPicker.setTypeface(Typeface.create(getString(R.string.roboto_light), Typeface.NORMAL));
numberPicker.setTypeface(getString(R.string.roboto_light), Typeface.NORMAL);
numberPicker.setTypeface(getString(R.string.roboto_light));
numberPicker.setTypeface(R.string.roboto_light, Typeface.NORMAL);
numberPicker.setTypeface(R.string.roboto_light);
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/409177.html
標籤:
上一篇:根據列名向量繪制多個不同的直方圖
