[英]How to decrease margin and padding of editText programmatically (android)
I have editText
which by default leaves lots of space. 我有
editText
,默认情况下会留很多空间。 I added backgroud for textView, cause editText backgroud is not possible. 我为textView添加了背景,因为不可能使用editText背景。
When I execute command:
editText.setHeight(50);
当我执行命令时:
editText.setHeight(50);
of no matter what integer it gives me same result:无论是什么整数,它都会给我相同的结果:
My text gets cropped. 我的文字被裁剪了。 I think somehow I need to reduce editText margins to fit my text here.
我认为我需要以某种方式减少editText的边距以适合此处的文本。
Main problem is that there is to much space between rows in first picture.
主要问题是第一张图片中的行之间有很多空间。
You can do like this 你可以这样
int reducedValue =5;
editText .setPadding(editText .getPaddingLeft()-reducedValue,
editText .getPaddingTop()-reducedValue,
editText .getPaddingRight()-reducedValue,
editText .getPaddingBottom()-reducedValue);
editText.setCompoundDrawablesWithIntrinsicBounds(editText .getPaddingLeft()-reducedValue,
editText .getPaddingTop()-reducedValue,
editText .getPaddingRight()-reducedValue,
editText .getPaddingBottom()-reducedValue);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.