-1

I am setting a textview with fromHtml(), and my TextView is not set in center. In below image you can show space bigger below of paragraf text, I don't know how to resolve this issue, other normal text it's fine but fromHtml its leave some space not in the center.

Setting textview like this

txtOffer.text = Html.fromHtml(<h1>Hello i am using your app</h1>, Html.FROM_HTML_MODE_LEGACY)

This is xml code

 <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorAccent"
            android:gravity="center">

            <android.support.v7.widget.AppCompatTextView
                android:id="@+id/txt_offer"
                style="@style/txt_heavy_oblique"
                android:gravity="center"
                android:padding="@dimen/ten_dp" 
                android:textColor="@android:color/white"
                android:textSize="@dimen/text_size_12" />

    </LinearLayout>

  <style name="txt_heavy_oblique" parent="ThemeOverlay.AppCompat.Light">
        <item name="android:textColor">@color/colorPrimaryText</item>
        <item name="android:textSize">@dimen/text_size_14</item>
        <item name="android:layout_width">match_parent</item>
        <item name="android:layout_height">wrap_content</item>
        <item name="android:textAppearance">@style/AvenirHeavyOblique</item>
    </style>

enter image description here

Sachin Rajput
  • 4,326
  • 2
  • 18
  • 29
Mohit Suthar
  • 8,725
  • 10
  • 37
  • 67

2 Answers2

0

don't use tag in html it will create margins problem. If you need only different size, you can use simple or and you can use it more times for one char. Example: "classic text is ok, but bigger is better".

Avinash Ajay Pandey
  • 1,497
  • 12
  • 19
0

Many research I found this lib, and its very useful and solve my problem

https://github.com/PrivacyApps/html-textview

Thanks to @Avinash Ajay Pandey for your support. :)

Mohit Suthar
  • 8,725
  • 10
  • 37
  • 67