Android之小技巧android:drawableRight
我们在写布局代码时,经常会忽略一些有用的代码技巧,以下图为例说明:
对于上面的“付款方式”一栏,很多时候会写一个相对布局,把右箭头作为一个单独view来处理,其实有更加好用的方法,它就是
android:drawableRight
当然, 也可以通过代码设置:
void android.widget.TextView.setCompoundDrawables(Drawable left, Drawable top, Drawable right, Drawable bottom)
总结:思路决定出路!