1
我正在尝试在微调器中自定义箭头图像。这里是我的代码:在Android微调器中设置自定义下拉箭头
LayoutInflater inflater = LayoutInflater.from(context);
spin = (Spinner) inflater.inflate(R.layout.spinner, null);
adapter = new ArrayAdapter<Choice>(context, R.layout.nitro_spinner_item, choicesArr);
adapter.setDropDownViewResource(R.layout.multiline_spinner_dropdown_item);
spin.setAdapter(adapter);
和R.layout.nitro_spinner_item.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="@android:id/text1"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableEnd="@drawable/ic_action_acf"
android:ellipsize="marquee"
android:singleLine="true"
android:textAlignment="inherit"/>
我看到我的自定义图像,与普通的Android沿下拉箭头。我用这里的答案作为参考:https://stackoverflow.com/a/30336734/1642002。如果我重写了文本视图,股票下拉图像来自哪里?
http://stackoverflow.com/questions/25028202/android-add-arrow-image-to-spinner –
也许是部分背景。如果您将@ android:background =“@ android:color/transparent”'添加到xml中,会发生什么情况 – Blackbelt
@Blackbelt:我试过了,箭头不能是textview本身的一部分。 – regretoverflow