Set the text in ImageButton

android, imagebutton

Solution

`ImageButton` cannot contain text:

Options you can try

1) use `Button` instead of `ImageButton`

2) use `ImageButton` and `TextView` below to show text

Hope this could help

Problem

I have a ImageButton which looks like this. ``` <ImageButton android:id="@+id/ImageButton" android:layout_width="200dp" android:layout_height="200dp" android:layout_gravity="center" android:layout_marginBottom="6px" android:layout_marginRight="3px" android:layout_toRightOf="@+id/Logo" android:background="@drawable/button_bg_purple" android:scaleType="fitStart" android:src="@drawable/ImageButton" /> ImageButton ImgButton= (ImageButton) this.findViewById(R.id.ImageButton); ``` Now I need to add a dynamic text in ImageButton programmatically and I cannot use button. How can I do it? Thanks In Advance ...

Original source