Spinner DropDown列表

时间:2015-05-01 12:07:55

标签: android

我有四个Spinner,它有一个带有下拉列表的自定义背景。单击第三个和第四个微调器时,其显示在微调器上方的列表不会向下旋转微调器。我的屏幕也有很多空间,但我不知道如何解决这个问题。 我使用下面的布局来显示微调器。

<?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="@drawable/background_screen"
    android:orientation="vertical" >

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:scrollbars="none" >

        <LinearLayout
            android:id="@+id/solarparent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="40dp"
                android:layout_marginTop="5dp"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:weightSum="2" >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.7"
                    android:text="Full Name"
                    android:textColor="@android:color/black"
                    android:textSize="@dimen/cippa_font" />

                <EditText
                    android:id="@+id/nameTxtView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:digits="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
                    android:ems="10"
                    android:singleLine="true"
                    android:textSize="@dimen/cippa_font" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:text="16"
                    android:visibility="gone" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:weightSum="2" >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.7"
                    android:text="System Size (kW)"
                    android:textColor="@android:color/black"
                    android:textSize="@dimen/cippa_font" />

                <EditText
                    android:id="@+id/ppaSystemSizeEditView"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:ems="10"
                    android:inputType="numberDecimal"
                    android:textSize="@dimen/cippa_font" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:text="kW"
                    android:visibility="gone" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="fill_parent"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:paddingTop="10dp"
                android:visibility="visible"
                android:weightSum="2" >

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="0.7"
                    android:gravity="center_vertical"
                    android:orientation="vertical" >

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:text="Annual Production"
                        android:textColor="@android:color/black"
                        android:textSize="@dimen/cippa_font" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:orientation="vertical" >

                    <RelativeLayout
                        android:id="@+id/annualLayout"
                        android:layout_width="fill_parent"
                        android:layout_height="40dp"
                        android:layout_gravity="center_vertical"
                        android:layout_weight="1.3"
                        android:background="@drawable/spinner_bg"
                        android:gravity="center_vertical" >

                        <TextView
                            android:id="@+id/annualTxyView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="5dp"
                            android:hint="Select"
                            android:singleLine="true"
                            android:textColor="#000000"
                            android:textColorHint="#000000"
                            android:textSize="@dimen/cippa_font" />
                    </RelativeLayout>
                </LinearLayout>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:text="kWh/kW/yr"
                    android:visibility="gone" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:paddingTop="10dp"
                android:visibility="visible"
                android:weightSum="2" >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="0.7"
                    android:gravity="center_vertical"
                    android:text="PPA Term (Years)"
                    android:textColor="@android:color/black"
                    android:textSize="@dimen/cippa_font" />

                <Spinner
                    android:id="@+id/ppaSpiner"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1.3"
                    android:background="@drawable/spinner_bg"
                    android:prompt="@string/spinner_title"
                    android:textSize="@dimen/cippa_font" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:text="Years"
                    android:visibility="gone" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:paddingTop="10dp"
                android:visibility="visible"
                android:weightSum="2" >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="0.7"
                    android:gravity="center_vertical"
                    android:text="PPA Escalation Rate (%)"
                    android:textColor="@android:color/black"
                    android:textSize="@dimen/cippa_font" />

                <Spinner
                    android:id="@+id/escalationSpiner"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1.3"
                    android:background="@drawable/spinner_bg"
                    android:prompt="@string/spinner_title" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:text="%"
                    android:visibility="gone" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:layout_gravity="center_vertical"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:paddingTop="10dp"
                android:weightSum="2" >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="0.7"
                    android:gravity="center_vertical"
                    android:text="PPA Cap (\u20B9/kWH)"
                    android:textColor="@android:color/black"
                    android:textSize="@dimen/cippa_font" />

                <Spinner
                    android:id="@+id/ppaCapSpiner"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1.3"
                    android:background="@drawable/spinner_bg"
                    android:textSize="@dimen/cippa_font" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:text="/kWH"
                    android:visibility="gone" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="50dp"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:paddingTop="10dp"
                android:weightSum="2" >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="0.7"
                    android:gravity="center_vertical"
                    android:text="Customer Deposit Tenure (Months)"
                    android:textColor="@android:color/black"
                    android:textSize="@dimen/cippa_font" />

                <Spinner
                    android:id="@+id/ppaDepositSpiner"
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1.3"
                    android:background="@drawable/spinner_bg"
                    android:prompt="@string/spinner_title" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:text="Months"
                    android:visibility="gone" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="fill_parent"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:paddingTop="10dp"
                android:weightSum="2" >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="0.7"
                    android:gravity="center_vertical"
                    android:text="Special Requirements"
                    android:textColor="@android:color/black"
                    android:textSize="@dimen/cippa_font" />

                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:layout_weight="1.3"
                    android:orientation="vertical" >

                    <RelativeLayout
                        android:id="@+id/requelayout"
                        android:layout_width="fill_parent"
                        android:layout_height="40dp"
                        android:layout_gravity="center_vertical"
                        android:background="@drawable/spinner_bg"
                        android:gravity="center_vertical" >

                        <TextView
                            android:id="@+id/spclDialogTxtView"
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_marginLeft="4dp"
                            android:text="Select"
                            android:textColor="#000000"
                            android:textSize="@dimen/cippa_font" />
                    </RelativeLayout>
                </LinearLayout>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:text="16"
                    android:visibility="gone" />
            </LinearLayout>

            <Button
                android:id="@+id/but_calculate"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="18dp"
                android:background="@drawable/login_btn_selector"
                android:text="Calculate"
                android:textColor="@android:color/white"
                android:textSize="@dimen/cippa_font" />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center_vertical"
                android:orientation="horizontal"
                android:paddingLeft="3dp"
                android:paddingRight="3dp"
                android:paddingTop="10dp"
                android:weightSum="2" >

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.7"
                    android:text="PPA Year 1 Rate (\u20B9/kWH)"
                    android:textColor="@android:color/black"
                    android:textSize="@dimen/cippa_font" />

                <TextView
                    android:id="@+id/ppayearrate"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_weight="1.3"
                    android:textSize="@dimen/cippa_font" />

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1.3"
                    android:text="16"
                    android:visibility="gone" />
            </LinearLayout>

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:layout_marginTop="20dp"
                android:gravity="center"
                android:orientation="horizontal"
                android:padding="3dp"
                android:weightSum="2" >

                <Button
                    android:id="@+id/but_cal_saving"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginRight="3dp"
                    android:layout_weight="1"
                    android:background="@drawable/login_btn_selector"
                    android:text="Calculate Savings"
                    android:textColor="@android:color/white"
                    android:textSize="@dimen/cippa_font" />

                <Button
                    android:id="@+id/but_Home"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    android:background="@drawable/login_btn_selector"
                    android:text="Home"
                    android:textColor="@android:color/white"
                    android:textSize="@dimen/cippa_font" />
            </LinearLayout>
        </LinearLayout>
    </ScrollView>

</RelativeLayout>


and below is my spinner.bg for Spinner background :


<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item><layer-list>
            <item><shape>
                    <gradient android:angle="90" android:endColor="#ffffff" android:startColor="#ffffff" android:type="linear" />

                    <stroke android:width="0.5dp" android:color="#504a4b" />

                    <corners android:radius="5dp" />

                    <padding android:bottom="3dp" android:left="3dp" android:right="3dp" android:top="3dp" />
                </shape></item>
            <item><bitmap android:gravity="center_vertical|right" android:src="@drawable/dropdown_spinner" />
            </item>
        </layer-list></item>

</selector> 

0 个答案:

没有答案