我正在使用 Spinner DropDownview
的自定义布局,它具有带有白色字母的棕色背景。 View 底部出现一些白色条纹 1 ,我想删除它,但我不知道它们是如何出现的,也不知道它们为什么会出现;
这是我用于 spinner_dropdown_item
的代码:
<CheckedTextView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@android:id/text1"
style="?android:attr/spinnerDropDownItemStyle"
android:layout_width="match_parent"
android:layout_height="@dimen/dropdownListPreferredItemHeight"
android:background="@color/marrom"
android:ellipsize="marquee"
android:gravity="center_vertical"
android:minHeight="@dimen/txt_min_height"
android:paddingEnd="@dimen/md_keylines"
android:paddingStart="@dimen/md_keylines"
android:singleLine="true"
android:textAllCaps="true"
android:textColor="@color/white"
android:textSize="@dimen/text_subtitle"
tools:text="spinner dropdown item" />
以及微调器适配器内的getDropdownView
:
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
T element = elements.get(position);
convertView = LayoutInflater.from(parent.getContext()).inflate(getDropdownLayout(), parent, false);
final TextView textView = (TextView) convertView;
textView.setText(getDisplayName(element));
return textView;
}
其中函数getDropdownLayout
返回上面的布局
最佳答案
经过一番研究,我偶然发现了一个建议:spinner with a rectangular border .
创建 9 个补丁图像(矩形框),帮助您设置不同分辨率的微调器。
创建 9 个补丁图像后,将其用作微调器的背景。
这里是一个链接,可以让创建 9pacth 图像变得简单:http://inloop.github.io/shadow4android/
这是我的例子:
关于java - 将自定义项目应用于微调器的下拉 View 时如何删除白色条纹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51047856/