首页 > 解决方案 > 自定义微调器上的小错误空间

问题描述

我只是将我的微调器自定义视图设置为下拉列表,它是支持的。但不知何故,“15”文本下方出现了一个小空间,因此它不会水平呈线性。

在此处输入图像描述

这是我的代码:

    <?xml version="1.0" encoding="utf-8"?>
<TextView 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="match_parent"
    android:gravity="center_horizontal"
    android:textSize="18sp"
    android:textStyle="bold"
    android:textColor="@color/white"
    android:textAlignment="center"
    android:background="@drawable/timepickerbutton"
    android:paddingEnd="20dp"
    app:drawableEndCompat="@drawable/ic_arrow_down_sign_to_navigate" />

标签: androidandroid-layout

解决方案


尝试将 height 参数更改为 wrap_content 并将 width 更改为 fill_parent

我的一个项目中有下一个自定义微调器项目,他后面没有任何其他布局,只有纯 XML 文件和一个 TextView,它可以按预期工作:

<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/customSpinnerItemTextView"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:padding="5dip"
    android:textColor="@color/vectorColor"
    android:textSize="20sp"
    tools:text="sometext" />

推荐阅读