How to set property “android:drawableTop” of a button at runtime

前端 未结 8 1039
名媛妹妹
名媛妹妹 2020-12-04 21:01

How to set property \"android:drawableTop\" of a button at runtime

8条回答
  •  一向
    一向 (楼主)
    2020-12-04 21:26

    Use

    button.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);

    Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use 0 if you do not want a Drawable there. The Drawables' bounds will be set to their intrinsic bounds.

    If you use

    button.setCompoundDrawables(left, top, right, bottom);

    Sets the Drawables (if any) to appear to the left of, above, to the right of, and below the text. Use null if you do not want a Drawable there. The Drawables must already have had setBounds(Rect) called.

提交回复
热议问题