[英]position of drawable inside edittext
我通过以下代码将可绘制对象放入edittext:
final Drawable x = getResources().getDrawable(R.drawable.del2);
x.setBounds(0, 0, x.getIntrinsicWidth(), x.getIntrinsicHeight());
atxt.setCompoundDrawables(null, null, x, null);
有了这段代码,我的可绘制对象显示在edittext的右侧,我想为其设置边距。 例如,如果我设置rightMargin:20dp,我的可绘制对象会稍微向左侧移动。 我该怎么做?
您是否尝试过类似的方法:
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(left, top, right, bottom);
x.setLayoutParams(lp);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.