不要显示numberpicker分隔符

问题描述 投票:0回答:2

我使用以下属性不显示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。

android divider numberpicker
2个回答
1
投票

使用此代码

 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;
            }

0
投票

试试这个:

 <style name="AppTheme" parent="AppBaseTheme">
   <item name="android:actionBarDivider">@null</item>
 </style>
© www.soinside.com 2019 - 2024. All rights reserved.