Take a look at my TextView:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:id="@+id/tv"
android:layout_width="300dp"
android:layout_height="50dp"
android:gravity="center"
android:background="@android:color/darker_gray"
android:text="5666" />
</LinearLayout>
here is some html text:
private static final String HTML_CONETNT = "<p>text example with centered alignment</p>\n";
and this is how I insert the html content into the textview:
mTv.setText(Html.fromHtml(HTML_CONETNT));
However, it's only centered horizontally. How can I get it to be vertically centered as well?
I attempted using css style:
private static final String HTML_CONETNT = "<p style=\"text-align: center\">text example with centered alignment</p>\n";
but unfortunately, it didn't work as intended.