【问题标题】:How can i move the arrow to the right side in Spinner如何在 Spinner 中将箭头移动到右侧
【发布时间】:2021-07-13 04:46:36
【问题描述】:

我正在尝试将箭头按钮移动到右侧,这样它就不会出现在我的文本中 任何人都可以帮助我?? Button

这是样式代码:

 <?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
        <layer-list>
            <item>
                <shape android:shape="rectangle">

                    <solid android:color="#FFFFFF"/>

                    <padding android:right="10dp"/>
                </shape>
            </item>
            <item>

                <bitmap      android:src="@drawable/style" android:gravity="center|right"/>
            </item>
        </layer-list>
    </item>

</selector>

我试图改变重力,但它不起作用

【问题讨论】:

  • 为什么不设置一个drawableEnd
  • 你能解释更多吗? @ADM
  • 我从图片中了解到的你需要在 Button 右侧有一个图标。这可以通过 android:drawableEnd="@drawable/arrow" 来完成。如果这不能解决您的问题,请添加更多关于预期和当前输出问题的详细信息。
  • 是的,这正是我需要的,但这是一个微调器,而不是一个按钮,我试着按照你说的去做,但它不会起作用,如果你想要我可以发送代码的图片@ADM跨度>
  • 您的代码看起来很好,它的微调器的宽度我猜这会导致重叠。见This thread

标签: android android-spinner


【解决方案1】:

嘿,你可以使用很有帮助的材料设计按钮

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:layout_constraintTop_toTopOf="parent"
    app:iconGravity="end"
    android:background="@android:color/white"
    android:backgroundTint="@android:color/white"
    android:text="A+20"
    app:icon="@drawable/ic_baseline_arrow_forward_24"
   style="@style/Widget.MaterialComponents.Button.TextButton.Icon"
/>

来源:https://material.io/components/buttons/android#text-button

【讨论】:

  • 谢谢,但它是一个微调器,所以我需要调整它?