android - 在 android 中隐藏 Spinner 下拉图标

标签 android xml android-spinner dropdown

我在 android 中有一个微调器,我使用微调器背景。但现在的问题是,我的图片上有一个向下箭头,android 添加了另一个向下箭头或类似的东西。现在我想删除 android 默认箭头图标。
这是图像 enter image description here

安卓java代码

ArrayAdapter<String> dataAdapterOfFromAccount = new ArrayAdapter<String>(context,
                R.layout.custom_simple_spinner, accountList);
        dataAdapterOfFromAccount.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spFromAccount.setAdapter(dataAdapterOfFromAccount);


自定义布局的custom_simple_spinner.xml

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/text1"
style="?android:attr/spinnerItemStyle"

android:layout_width="match_parent"
android:layout_height="50dp"
android:ellipsize="marquee"
android:gravity="center_vertical"

android:paddingRight="35dp"
android:background="@drawable/btn_selector" />

我用的是这种风格的代码

<style name="mySpinnerStyle" parent="@android:style/Widget.Spinner">
    <item name="android:divider">#01579B</item>
    <item name="android:dividerHeight">1dp</item>


</style>

现在请,任何人都可以帮我解决这个问题,我想删除那些默认的下拉图标。提前致谢 。 我正在使用 Android 6.0(API 级别 23) 它适用于 Android 5(API 级别 22),但在 Android 6 中会产生问题。

最佳答案

隐藏下拉图标

 <Spinner
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:background="@android:color/transparent"/>

或覆盖另一个 View

<RelativeLayout
  android:layout_width="match_parent"
  android:layout_height="wrap_content">

  <Spinner
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_centerVertical="true"/>

  <ImageView
      android:layout_width="30dp"
      android:layout_height="30dp"
      android:layout_alignParentEnd="true"
      android:layout_centerVertical="true"
      android:background="#fff"/>
</RelativeLayout>

关于android - 在 android 中隐藏 Spinner 下拉图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33438190/

相关文章:

安卓 M 权限 : checkSelfPermission() always returns -1

android - 如何在 Android Studio 中禁用设备监控?

php - Xpath查询结果始终为空

android - ImageView 源总是覆盖它的背景 Android

java - Android 分水岭 OpenCV

java - 将 GsonBuilder 转换为 Kotlin

xml - 元素 "context"的前缀 "context:component-scan"未绑定(bind)

Android:隐藏键盘并在微调器关闭后再次显示

选择项目上的android微调器点击监听器不触发

android - 微调器文本中心垂直和水平对齐