首页 > 解决方案 > 按钮错误地用drawable内部包装内容

问题描述

在使用 android 按钮时,我不断回到同样的问题......当我尝试向按钮添加可绘制对象时,按钮会错误地构建可绘制对象。

按钮代码:

<Button
        android:id="@+id/cancel_directions_button_v2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:drawableBottom="@drawable/i_close"
        app:layout_constraintStart_toEndOf="@id/info_directions_textview"
        app:layout_constraintBottom_toBottomOf="parent"
        android:backgroundTint="@color/colorPrimary"
        android:layout_marginBottom="26sp"
        android:visibility="gone"
        />

照片: 在此处输入图像描述

标签: androidandroid-studioandroid-layoutandroid-button

解决方案


尝试改用 ImageButton。

<ImageButton
    .
    .
    .
    android:src="@android:drawable/i_close" />

推荐阅读