我发现更改微调器下拉图标的解决方案:
1.创建自定义drawable
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/vector_drawable_ic_dropdown_black" android:state_focused="true" android:state_pressed="false" />
<item android:drawable="@drawable/vector_drawable_ic_dropdown_black" android:state_focused="true" android:state_pressed="true" />
<item android:drawable="@drawable/vector_drawable_ic_dropdown_black" android:state_focused="false" android:state_pressed="true" />
<item android:drawable="@drawable/vector_drawable_ic_dropdown_black" />
</selector>
2.将drawable设置为spinner背景:
<Spinner
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:background="@drawable/custom_spinner_icon"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:textColor="@color/textcolorprimary" />
结果是:
如您所见,这不是一个可接受的解决方案,因为图标需要右对齐而不是拉伸。
我该怎么做才能使图标不拉伸并正确对齐?
编辑
由于还没有可行的解决方案,我想我必须指定我的问题。这是我的 Spinner 使用标准主题的外观:
<Spinner
android:id="@+id/products_download_spinner_language"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:gravity="center"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:textColor="@color/textcolorprimary"
android:theme="@android:style/Theme.Holo.Light.DarkActionBar" />
我想要的一切(我猜这真的不多)正在改变箭头。我不希望显示右下角的那个箭头,我希望这个箭头垂直居中显示在右边:
以及到目前为止我尝试过的每个解决方案:
根本没有工作。他们有拉伸图标或底线丢失或其他完全错误的东西。我只是想要另一个箭头。
原文由 Mulgard 发布,翻译遵循 CC BY-SA 4.0 许可协议
尝试使用以下样式应用到您的微调器
// 微调器样式:
// bg_spinner.xml 用你的箭头替换 arrow_down_gray