【发布时间】:2013-03-26 06:02:47
【问题描述】:
我有一个按钮,我想在按钮文本的左边放一张图片。
Button b = new Button(this);
l.addView(b);
LinearLayout.LayoutParams pa = new LinearLayout.LayoutParams(-1, -2);
b.setLayoutParams(pa);
b.setText("Prueba");
Drawable img = getResources().getDrawable(R.drawable.ic_launcher);
b.setCompoundDrawablesWithIntrinsicBounds(img, null, null, null);
但是按钮宽度匹配父元素,图像对齐按钮左侧,文本对齐按钮中心。
编辑:
我看到了
..但我希望图像仅对齐左侧文本,而不仅仅是按钮左边缘的右侧
我想看到这样的:
http://img543.imageshack.us/img543/6534/img20130404111534.jpg
有什么想法吗?
【问题讨论】:
-
那么问题是什么?
-
查看我在问题中提出的图像。图像与文本的左侧对齐,但不仅仅是文本的左侧..
-
图像已经在左侧,但您希望文本在哪里?
-
我想看看我在问题中放的最后一张照片(对不起,我之前忘记放了)
标签: android image button android-drawable