我找到的解决方案更改了微调器下拉图标,其中所有:
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>
Run Code Online (Sandbox Code Playgroud)
2.将drawable设置为微调器背景:
<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" />
Run Code Online (Sandbox Code Playgroud)
结果是:
正如您所看到的,这不是一个可接受的解决方案,因为图标需要右对齐而不是拉伸.
我该怎么做才能使图标不拉伸并对齐?
编辑
由于没有可行的解决方案,我想我必须指出我的问题.这就是我的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" />
Run Code Online (Sandbox Code Playgroud)
而我想要的一切(我猜这真的不多)正在改变箭头.我不希望显示右下角的箭头,我希望这个箭头垂直居中显示在右边:
到目前为止我尝试的每个解决方案:
根本没工作.他们有拉伸的图标或底线缺失或其他东西完全错误.我只想要另一支箭.
我创建了一个用于旋转器的背景drawable.我想现在,但在这个背景中的箭头图像.我尝试过像android:drawableRight ="arrowimage"这样的东西,但这似乎没有显示任何东西.有谁知道如何在我的自定义背景中为旋转器包含图像?