数字选择器没有作为设计师正确显示

时间:2016-01-28 09:58:28

标签: java android

Android Studio中的数字选择器控件存在一些问题。运行应用程序时,控件在实际设备上没有正确显示。数字选择器没有灰色背景颜色,没有" +" /" - "按钮显示,它们都像透明?

Android studio designer 这是XML

     <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#000000"
    >

    <ExpandableListView
        android:layout_width="wrap_content"
        android:layout_height="342dp"
        android:id="@+id/lvTranExp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"

        android:layout_above="@+id/numberPicker"
        android:layout_alignParentTop="true" />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/lvTranExp"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true">

        <NumberPicker
            android:scaleX="0.5"
            android:scaleY="0.5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/numberPickerStartDay"
            android:layout_below="@+id/lvTranExp"
            android:layout_toLeftOf="@+id/numberPickerStartDay"
            android:layout_toStartOf="@+id/numberPickerStartDay"
            android:solidColor="#da9c9c" />

        <NumberPicker
            android:scaleX="0.5"
            android:scaleY="0.5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/numberPickerStartMonth"
            android:layout_below="@+id/lvTranExp"
            android:layout_toRightOf="@+id/numberPickerStartDay"
            android:layout_toEndOf="@+id/numberPickerStartDay"
            android:solidColor="#895353" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Start date"

            android:textColor="#e9e97619"
            android:id="@+id/textView5"
            android:layout_below="@+id/lvTranExp"
       android:layout_alignBottom="@+id/numberPicker1"
            android:layout_marginLeft="40dp"

            android:layout_gravity="center" />
    </LinearLayout>


</RelativeLayout>

这是数字选择器的Java代码:

 View contentView = inflater.inflate(R.layout.activity_transactions, null);
    NumberPicker startDay = (NumberPicker)contentView.findViewById(R.id.numberPickerStartDay);
    NumberPicker startMonth = (NumberPicker)contentView.findViewById(R.id.numberPickerStartMonth);
    String []days = new String[31];
    for(int i =0;i<days.length;i++){
        days[i]=Integer.toString(i+1);
    }
    String []months = new String[12];
    for(int i =0;i<months.length;i++){
        months[i]=Integer.toString(i+1);
    }
    startDay.setMinValue(1);
    startDay.setMaxValue(31);
    startDay.setWrapSelectorWheel(false);
    startDay.setDisplayedValues(days);
    startDay.setValue(1);

    startMonth.setMinValue(1);
    startMonth.setMaxValue(12);
    startMonth.setWrapSelectorWheel(false);
    startMonth.setDisplayedValues(months);
    startMonth.setValue(1);

这是设备截图: enter image description here

提前致谢

0 个答案:

没有答案