TextView without any default padding [duplicate]

…衆ロ難τιáo~ 提交于 2019-12-10 15:34:00

问题


Possible Duplicate:
I want textView without any default padding while increasing size of textView

I want to remove default padding on TextView. When i increase the size of TextView then its padding size increases automatically. even i set background of text View as "@null". i just want to show only text without any padding. my View looks like this first images and i want to show like second images.

This First link shows View is displaying.

http://www.imageurlhost.com/images/487vskfx1aj01f9e9g40.png

This second link show Layout view that i want to show without giving any -margin

http://www.imageurlhost.com/images/ijuyxpcub1oqy1w66h.png


回答1:


It's called font padding. You can disable it with mTextView.setIncludeFontPadding(false); or xml attribute android:includeFontPadding="false"




回答2:


You can remove the padding from xml by setting the padding to 0dp

Try something like this:

<TextView
    android:padding="0dp"
 ...
 </TextView>

Note that if you do that, you can't use gravity anymore, since that is working using padding.

If you want to remove only top and bottom padding, you can set paddingBottom and paddingTop to 0dp and work with the side padding.

Cheers, Arkde



来源:https://stackoverflow.com/questions/12172784/textview-without-any-default-padding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!