0

I put a drawable into a edittext by this code:

    final Drawable x = getResources().getDrawable(R.drawable.del2);
    x.setBounds(0, 0, x.getIntrinsicWidth(), x.getIntrinsicHeight());
    atxt.setCompoundDrawables(null, null, x, null);

With this code my drawable shows in right side of edittext, I want to set margin for it. For example if i set rightMargin:20dp my drawable goes a little to left side. How i can do this?

Fcoder
  • 9,066
  • 17
  • 63
  • 100

1 Answers1

0

Have you tried something like:

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(left, top, right, bottom);
x.setLayoutParams(lp);

More info

Community
  • 1
  • 1
Nick
  • 9,285
  • 33
  • 104
  • 147