您的位置:首页 > 移动开发 > Android开发

Android设置图片和文本相对位置

2015-05-18 16:08 375 查看
在代码中设置文本与图片的相对位置时,可以用setCompoundDrawables(left, top, right, bottom)方法。

方法非常简单首先需要使用setBounds(int left, int top, int right, int bottom)给图片设置边界,然后再使用

setCompoundDrawables(left, top, right, bottom)方法设置图片的位置。

Drawable drawable = getResources().getDrawable(R.drawable.back_arrow);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
goBackTextView.setCompoundDrawables(null, null, null, drawable);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  android 位置
相关文章推荐