I am trying to have an text and image on a button appear dynamically - the text needs to appear on the left and the image to appear on the right. To give an example, here is an image I would like to get.
After searching through a few other examples on StackOverflow, tried the following code in my activity but it doesnt seem to be working. Can anyone please suggest what I am doing wrong ?
Code :
btn.setTextColor(Color.parseColor("#000000"));
btn.setText("SomeText");
btn.setTextSize(TypedValue.COMPLEX_UNIT_PX, mediumTextSize);
Drawable icon= getApplicationContext().getResources().getDrawable( R.drawable.cal);
icon.setBounds(0, 0, 0, 0); //Left,Top,Right,Bottom
btn.setCompoundDrawablesWithIntrinsicBounds( null, null, icon, null );

ImageButtonLinearLayoutand apply stylebtn.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.cal, 0);?