如何刪除分隔線數量選擇器,我試圖setShowDivider爲none(無,似乎不存在)通過XML和代碼注意到工作安卓:如何刪除分隔線數量拾取
picker.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
XML :
android:showDividers="none"
如何刪除分隔線數量選擇器,我試圖setShowDivider爲none(無,似乎不存在)通過XML和代碼注意到工作安卓:如何刪除分隔線數量拾取
picker.setShowDividers(LinearLayout.SHOW_DIVIDER_NONE);
XML :
android:showDividers="none"
集的主題爲Numberpicker
<NumberPicker
...
android:theme="@style/DefaultNumberPickerTheme" />
style.xml
<style name="DefaultNumberPickerTheme" parent="AppTheme">
<item name="colorControlNormal">@color/transparent</item>
</style>
OR
private void changeDividerColor(NumberPicker picker, int color) {
java.lang.reflect.Field[] pickerFields = NumberPicker.class.getDeclaredFields();
for (java.lang.reflect.Field pf : pickerFields) {
if (pf.getName().equals("mSelectionDivider")) {
pf.setAccessible(true);
try {
ColorDrawable colorDrawable = new ColorDrawable(color);
pf.set(picker, colorDrawable);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (Resources.NotFoundException e) {
e.printStackTrace();
}
catch (IllegalAccessException e) {
e.printStackTrace();
}
break;
}
}
}
,並設置爲
changeDividerColor(yournumberpicker, Color.parseColor("#00ffffff"));
該代碼會更好
private void changeDividerColor(NumberPicker picker, int color) {
try {
Field mField = NumberPicker.class.getDeclaredField("mSelectionDivider");
mField.setAccessible(true);
ColorDrawable colorDrawable = new ColorDrawable(color);
mField.set(picker, colorDrawable);
} catch (Exception e) {
e.printStackTrace();
}
}
屏幕截圖可能會有幫助,也許 – Vucko
確定添加,尖銳的,圍繞着1 – blackHawk
的天藍色線條使其透明而不是刪除 –