androidtextviewandroid-widgetandroid-background

background drawable does not fit in bound of TextView in Android


I made a TextView which has attributes of background, gravity and so on. and i made a drawable resource file for the TextView's background. and this is the xml. enter image description here

and i added the drawable resource into background of the TextView. enter image description here

but the problem is, the background doesn't fit in Textview's bound. please look at this photo.

enter image description here

there is a gap very slightly. the background color area is upper than TextView's area. so i tried to use includeFontPadding attribute but it didn't work. how can i fix it?


Solution

  • I would advise you to check this on real device/emulator, not on preview in AS. use Show Layout Bounds option from developer options for verification, make some full-resolution screen shot and check on it. it will be properly placed

    content of any View, including its background, is always places inside its bounds. really, always, its just impossible to get outside with a single pixel (due to layout building and drawing mechanism)