I have this kind of price html from server
<del><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">₹</span>12,000.00</span></del> <ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">₹</span>3,999.00</span></ins>
I am using HTMLCompact to render it in textview
HtmlCompat.fromHtml(description, HtmlCompat.FROM_HTML_MODE_COMPACT)
But discount text is not StrikeThrough. Del tag is completely being ingnored.
Code Implementation as requested
<TextView
android:id="@+id/course_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:fontFamily="@font/open_sans_semi_bold"
app:renderHtmlText="@{viewModel.product.priceHtml}"
android:textSize="18sp" />
//Binding Adapter
@BindingAdapter("renderHtmlText")
fun bindRenderHtmlText(view: TextView, description: String?) {
if (description != null) {
view.text = HtmlCompat.fromHtml(description, HtmlCompat.FROM_HTML_MODE_COMPACT)
} else {
view.text = ""
}
}
Based on the logic of handleEndTag
from Android framework source, outer del
tag might be ignored by inner span
tag.
The suggestion solution is add an inline style style="text-decoration: line-through;
for compatibility like below.
<del>
<span class="woocommerce-Price-amount amount" style="text-decoration: line-through;">
<span class="woocommerce-Price-currencySymbol">₹</span>12,000.00
</span>
</del>
<ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">₹</span>3,999.00</span>
Or ajdust your html page structure to make del
tag inside span
tag.
<span class="woocommerce-Price-amount amount">
<span class="woocommerce-Price-currencySymbol"><del>₹</del></span><del>12,000.00</del>
</span>
<ins><span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">₹</span>3,999.00</span>
</ins>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With