Reputation: 1755
I'm using a HtmlView for some html text I get through a json feed. However, I want to center it under an image and am having trouble figuring out how to style the elements inside the view. I know how to set the width of the element itself, but how do I style the content?
Upvotes: 0
Views: 1021
Reputation: 21908
Use text-align
with style attribute,
<HtmlView html="<div style='text-align: center'>this text should be in center of view</div>"></HtmlView>
Note: I was told that text-align: center
may not work in Android < v7.0. In which case you will have to set the gravity on native view.
// Do this in loaded event of TextView
const nativeView = args.object.android;
if (nativeView) {
nativeView.setGravity(android.view.Gravity.CENTER_HORIZONTAL);
}
Here is a Playground sample.
Upvotes: 1