添加空白行时微调器显示不正确

时间:2019-03-31 06:05:43

标签: android android-spinner

我在recyclerview行中显示微调器。当我使用“添加成员”按钮添加空白行时,微调框显示的图像如下图所示enter image description here

请帮助我。我在Google上搜索,但没有得到任何解决方案 这是该屏幕的布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="10dp">

    <TextView
        android:id="@+id/txt_numbertitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:letterSpacing="0.01"
        android:lineSpacingExtra="2sp"
        android:text="First Member"
        android:textColor="#424242"
        android:textSize="16sp" />

    <ImageView
        android:id="@+id/img_delete"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:srcCompat="@drawable/ic_delete"
        android:layout_alignParentRight="true"/>
</RelativeLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="20dp"
    android:orientation="horizontal">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1.0">

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp">

            <EditText
                android:id="@+id/edt_name"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginRight="20dp"
                android:backgroundTint="@color/colorPrimary"
                android:hint="First Name"
                android:inputType="text"
                android:maxLines="1"
                android:textColor="@color/textcolor"
                android:textColorHint="@color/hintcolor" />

        </android.support.design.widget.TextInputLayout>

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_weight="1.0">

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp">

            <EditText
                android:id="@+id/edt_surname"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/colorPrimary"
                android:hint="Last Name"
                android:inputType="text"
                android:maxLines="1"
                android:textColor="@color/textcolor"
                android:textColorHint="@color/hintcolor" />

        </android.support.design.widget.TextInputLayout>

    </LinearLayout>

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:gravity="bottom"
    android:orientation="horizontal">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1.0">

        <Spinner
            android:id="@+id/sp_relation"
            style="@style/Widget.AppCompat.Spinner.Underlined"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginRight="5dp"
            android:backgroundTint="@color/colorAccent"
            android:dropDownVerticalOffset="35dp"
            android:entries="@array/relation"
            android:spinnerMode="dropdown"
            android:theme="@style/ThemeSpinner" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_weight="1.0">

        <android.support.design.widget.TextInputLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <EditText
                android:id="@+id/edt_city"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:backgroundTint="@color/colorPrimary"
                android:hint="City"
                android:inputType="text"
                android:maxLines="1"
                android:textColor="@color/textcolor"
                android:textColorHint="@color/hintcolor" />

            </android.support.design.widget.TextInputLayout>

        </LinearLayout>
    </LinearLayout>

</LinearLayout>

这是recyclerview行的布局。当用数组填充数据时,微调器显示正确的微调器,但是当我添加空白行时,它显示如下图所示

 <style name="ThemeSpinner">
    <!-- Color when pressed -->
    <item name="colorAccent">#ffa000</item>
    <!-- Default color for the dropdown arrow and line -->
    <item name="colorControlNormal">#ffc107</item>
    <item name="android:textColor">@color/colorPrimaryDark</item>
</style>

这是应用于微调器的主题

1 个答案:

答案 0 :(得分:0)

尝试将layout_height的值更改为wrap_content

如果自定义背景是xml可绘制文件,请检查是否未在底部使用填充。