How to add image(left) and text on button?
For illustration:
ImageButton can't have text (or, at least, android:text isn't listed in its attributes).
Copy your image file within the Res/drawable/ directory of your project. While in XML simply go into the graphic representation (for simplicity) of your XML file and click on your ImageButton widget that you added, go to its properties sheet and click on the [...] in the src: field. Simply navigate to your image file.
use android:drawableLeft="@drawable/image"
in your layout xml
you can also do this from code
Drawable icon= getContext().getResources().getDrawable( R.drawable.image); button.setCompoundDrawablesWithIntrinsicBounds( icon, null, null, null );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With