Removing the bottom Padding from a TextView while using HTML Format

Removing the bottom Padding from a TextView while using HTML Format

By : S.MO
Date : October 17 2020, 06:10 AM
Any of those help This extra space that you see is infact line break followed by another line break.
When you dive into the Html.fromHtml(...) implementation which is used internally by HtmlCompat.fromHtml, you'll come across the following method that handles paragraph tags:
code :
private static void handleP(SpannableStringBuilder text) {
    int len = text.length();

    if (len >= 1 && text.charAt(len - 1) == '\n') {
        if (len >= 2 && text.charAt(len - 2) == '\n') {


    if (len != 0) {
 String html = "<p>This is the awesome place to gain</p><p><strong>awesomeness </strong>and <em>deliciuosness. </em>very<em> </em><u>nice</u></p>"

CharSequence trimmedString = trim(Html.fromHtml(html));

public static CharSequence trim(CharSequence s) {
        int start = 0;
        int end = s.length();
        while (start < end && Character.isWhitespace(s.charAt(start))) {

        while (end > start && Character.isWhitespace(s.charAt(end - 1))) {

        return s.subSequence(start, end);

Share : facebook icon twitter icon
Unexpected top and bottom padding on a TextView?

Unexpected top and bottom padding on a TextView?

By : mim
Date : March 29 2020, 07:55 AM
wish help you to fix your issue I have a TextView. I want to set its background color. But the color fills more top space than it does bottom space. , Add the following attribute:
code :
How can I get the size in pixels of the space below the text of a textview? (not the bottom padding)

How can I get the size in pixels of the space below the text of a textview? (not the bottom padding)

By : BeyinIscisi
Date : March 29 2020, 07:55 AM
help you fix your problem What happens if you put a 'g', 'p', 'y', or 'j' in your TextView? Each of these characters has a descender, and the metrics for the font will always allocate space for this feature of many scripts. This is to allow for the fact that multiple lines of flowing text ought not be crammed into each other.
If you really need to get the size of a font's descender, you can use a Paint object, load it with a Typeface and ask for its descent(). But a TextView I don't think is going to change the way it renders its lines for you. If you must ignore the descent, draw your own text in a custom view.
Android: TextView: Remove spacing and padding on top and bottom

Android: TextView: Remove spacing and padding on top and bottom

By : Alex Estrada
Date : March 29 2020, 07:55 AM
hope this fix your issue When I have a TextView with a \n in the text,, on the right I have two singleLine TextViews, one below the other with no spacing in between. I have set the following for all three TextViews.
Removing padding from TextView and ImageButton

Removing padding from TextView and ImageButton

By : jam
Date : March 29 2020, 07:55 AM
seems to work fine Set the value of android:scaleType attribute to fitXY as below and add the attribute to your ImageButton.
TextView strip away top and bottom padding for easier aligning?

TextView strip away top and bottom padding for easier aligning?

By : Kyle Swope
Date : March 29 2020, 07:55 AM
this will help I'm trying to align the top of a TextView (which will always be an integer greater than 0) and an ImageView. , Try this:
Related Posts Related Posts :
  • Media player not playing mp3 on Android API 28
  • Restarting an activity in a single tab in a TabActivity?
  • What's the recommended way of create Android libraries for use in apps?
  • Kubuntu 9.10 Android device not properly detected
  • Easiest way to implement RSS reader on Google Android?
  • Using date functions in android application?
  • Clickable LinearLayout not flashing on click
  • Horizontal scroll required(Android)
  • ViewFlipper caching issue
  • How to change theme for AlertDialog
  • Open-sided Android stroke?
  • Android numeric password field
  • How will the Toast be displayed, based on Activity/Fragment height and width (or) Device Screen width and height?
  • java.lang.IllegalStateException: Places must be initialized
  • How to implement GeckoView?
  • ARCore for older android devices
  • Could not resolve org.kodein.di:kodein-di-framework-android
  • Exoplayer playback error after interstitial ad
  • Custom lint rule for the `when condition` check
  • Is there a way to know when an app uses a permission in real time?
  • Unsupported Modules Detected: Unfortunately you can't have non-Gradle Java modules and Android-Gradle modules in one pro
  • Android-studio 3.4.0-3.4.2 Gradle ERROR: No value has been specified for property 'manifestOutputDirectory'
  • Emulator not able to run on MacOs. Emulator claims that OS is out of date
  • How to start socket.io like foreground service to stay connected and listen for messages
  • How to display Snackbar above BottomNavigationView & move FAB?
  • how to prevent recyclerview auto scroll to bottom when insert new items?
  • React native - Make sure your bundle is packaged correctly or you're running a packager server release mode
  • UI doesn't update until tap on the screen when setState is called inside a realm listener callback
  • Android XML binding of MutableLiveData not working
  • How to make textinputedittext editable and uneditable programmatically
  • Can't load Kernel binary: Invalid kernel binary format version. No active package webdev
  • What is the use of {@url} in actions.xml app action URL templates?
  • How to implement device stored card(ios & android) to pay for application?
  • Is it good practice implementing Parcelable on a Room database entity?
  • What is the correct way of starting and stopping camera using CameraX?
  • Android: Add support for in-app updates in application
  • Can I record video with CameraX (Android Jetpack)?
  • Resources task gives error and appcompat-v7 is not loaded
  • Android CameraX doesn't show anything
  • XML constraint layout: Elements placed on top of each other, fix?
  • Flutter - dynamic height on a tab
  • With Scoped Storage introduced in Android Q, how am I supposed to develop a file manager app?
  • Can't resolve symbol android.support.v4.util.Pools in react-native-gesture-handler
  • Jetpack Compose: Could not set unknown property 'useIR'
  • SQLiteException: file is not a database while upgrading sqlcipher version from 3 to 4
  • What are best practices of implementing user login session in android application?
  • Button text not aligned center vertically in react native
  • "flutter (os error: no address associated with hostname, errno = 7)" only for android
  • How to catch platformException in flutter/dart?
  • Unable to connect to ADB
  • How can I test In-app updates in Android?
  • How to apply multiple generics in a function using Kotlin
  • Gradle DSL method not found: 'kapt()'
  • Android ADB: How to push multiple files, into an emulator?
  • How to run a multiple AND query with Android Room?
  • How do i fix the getting null location value from FusedLocationProviderClient in android
  • Which ad formats uses tinder?
  • How to perform delete api in retrofit
  • AWS AppSync Error - AWSMobileClientStore.get(String) on null object reference
  • How to make back button on WebView work in onBackPressed?
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk