If you want change drawableLeft/Right/Top/Bottom property of view at run time then use following method
Download Complete Example
Screen Shot :
- setCompoundDrawablesWithIntrinsicBounds(int left,int top,int right,int bottom)
- setPadding(int left, int top, int right, int bottom) : Set layout padding
- setCompoundDrawablePadding: Set drawable padding
editTextDrawableLeft = (EditText)findViewById(R.id.editText_drawable_left);
textViewDrawableRight =(TextView)findViewById(R.id.textView_drawable_right);
//here we are setting image to left side of editText
editTextDrawableLeft.setCompoundDrawablesWithIntrinsicBounds(R.drawable.user_profile,0,0,0);
//now set the padding and drawable to editText
editTextDrawableLeft.setPadding(10,10,10,10);
editTextDrawableLeft.setCompoundDrawablePadding(20);
//now set the drable to textView
textViewDrawableRight.setCompoundDrawablesWithIntrinsicBounds(0,0,R.drawable.user_profile,0);
textViewDrawableRight.setPadding(10,10,10,10);
textViewDrawableRight.setCompoundDrawablePadding(20)
Download Complete Example
Screen Shot :
