约束drawableLeft / drawableRight的高度的TextView的高度高度、drawableLeft、drawableRight、TextView

2023-09-08 08:46:13 作者:莫想莫念莫犯贱。

我有如下的的TextView

<TextView
    android:drawableLeft="@drawable/loading"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Updating Rates" />

和结果是这样的:

如何让我的装载圆绘制约束比例如此高度的文本的高度匹配?

How do I make the loading circle drawable constrain proportionally so its height matches the height of the text?

另外,如果可能的话,我想补充的文本和图像之间有一些间隔。

Also, if possible, I would like to add some spacing between the text and the image.

推荐答案

为了让加载小才使图象更小。

To make the loading smaller just make the images smaller.

或者使用 RelativeLayout的,把装在一个的ImageView 并进行缩放。

Or use RelativeLayout and put the loading in an ImageView and scale it.

或者可以将可绘制并使用文本android:drawablePadding (或setCompoundDrawablePadding()):

Or you can add padding between the drawables and the text using android:drawablePadding (or setCompoundDrawablePadding()):

android:drawablePadding="3dp"