2013-05-08 62 views
1

我想添加一個圖像在按鈕上的文字。如果我添加圖像作爲按鈕的背景,它會被添加到文本下方。預期結果將添加爲圖像。請幫助安卓按鈕文本交叉(錯誤符號)圖像

Text below the image

更新: 我需要以編程方式做到這一點。

+0

添加一個TextView和ImageView的一個FrameLayout裏內 – JiTHiN 2013-05-08 11:59:29

回答

1

在XML中,

<RelativeLayout android:id="@+id/container">* 
    <TextView ...></TextView> <!-- Your A text --> 
</RelativeLayout> 

在代碼中,

RelativeLayout container = (Rel...) findViewById(R.id.container); 
ImageView imgView = new ImageView(this); 
// Set Image View params and image and add it programmatically 
container.addView(imgView); 
+0

感謝的要求,我想有它的一個按鈕。 – user1611248 2013-05-13 15:27:07