我使用以下属性不显示numberpicker分隔符,但它没有任何效果
<NumberPicker
android:id="@+id/TNP_M"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:showDividers="none"/>
有什么问题,我应该使用另一个属性来做到这一点吗?
UPDATE-1
我改变了高度和宽度,现在你可以看到分隔符的位置不正确,所以我决定不显示它们,我将“showDivders”属性设置为“none”但它不会影响numbetpicker。
使用此代码
Field[] pickerFields = NumberPicker.class.getDeclaredFields();
for (Field pf : pickerFields) {
if (pf.getName().equals("mSelectionDivider")) {
pf.setAccessible(true);
try {
pf.set(daypicker, new ColorDrawable(getResources().getColor(R.color.transparent)));
pf.set(mounthpicker, new ColorDrawable(getResources().getColor(R.color.transparent)));
pf.set(yearpicker, new ColorDrawable(getResources().getColor(R.color.transparent)));
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (Resources.NotFoundException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
break;
}
试试这个:
<style name="AppTheme" parent="AppBaseTheme">
<item name="android:actionBarDivider">@null</item>
</style>