gpt4 book ai didi

android - 以编程方式更改按钮的 drawableLeft

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:05:43 26 4
gpt4 key购买 nike

我正在使用一个按钮

<Button
android:id="@+id/zoom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/trans"
android:drawableLeft="@drawable/left_img"
android:fontFamily="arial"
android:text="My Name is "
android:textSize="50sp" />

并使用 :

更改其文本颜色
zoom.setTextColor(Color.parseColor("voilet"));

但无法理解如何更改其图像??

最佳答案

试试这个:

int imgResource = R.drawable.left_img;
button.setCompoundDrawablesWithIntrinsicBounds(imgResource, 0, 0, 0);

Reference

关于android - 以编程方式更改按钮的 drawableLeft,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18278003/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com