gpt4 book ai didi

android - TextView添加drawable的不同方式

转载 作者:IT老高 更新时间:2023-10-28 23:29:43 32 4
gpt4 key购买 nike

TextView 之间的区别在哪里?的方法来设置drawable?文档很模糊。

1) setCompoundDrawables (Drawable left, Drawable top, Drawable right, Drawable bottom)
2) setCompoundDrawablesRelative (Drawable start, Drawable top, Drawable end, Drawable bottom)
3) setCompoundDrawablesWithIntrinsicBounds(Drawable left, Drawable top, Drawable right, Drawable bottom)
4) setCompoundDrawablesRelativeWithIntrinsicBounds(Drawable start, Drawable top, Drawable end, Drawable bottom)

提前致谢。

最佳答案

setCompoundDrawables 要求您在 Drawable(s) 上手动调用 setBounds(Rect),而 setCompoundDrawablesWithIntrinsicBounds将为您确定 Drawable 的边界(有点像将 ImageView 设置为 wrap_content)。

setCompoundDrawablesRelativesetCompoundDrawables 相同,除了不使用“left”和“right”,它使用“start”和“end”,如果你希望同时支持从左到右和从右到左的本地化 (see this blog post for more info)。这同样适用于 setCompoundDrawablesRelativeWithIntrinsicBoundssetCompoundDrawablesWithIntrinsicBounds

关于android - TextView添加drawable的不同方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26204675/

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