Reputation: 638
I am Using a third party Library richeditor-android.
The Library is Great in it self and uses android web-view to provide text rich features. When you are done editing a text you can take it as a string and show it in the same Rich Editor's web-view after using
setInputEnabled(false)
But the problem is that web-view doesn't wrap text and instead enables horizontal scroll view for words longer than the screen.(The result is same with a normal web-view) I want the web-view to show the text in a similar pattern that it used to show it when I was editing the text.
I have Used everything mentioned in various answers available on stack overflow but no success yet. The main Problem is I want to disable only horizontal scroll while allow user to scroll vertically.
I have inserted images for example.
Image when I am entering the text.
Image when I am showing the Text.
Upvotes: 1
Views: 2134
Reputation: 422
Try the below code to remove the horizontal scroll using CSS.
Make a .css file in your assets folder, and paste the below code in that file.
.wrap {
word-wrap:break-word;
}
After that in your Activity put the below code.
StringBuilder sb = new StringBuilder();
sb.append("<HTML><HEAD><LINK href=\"justify.css\" type=\"text/css\" rel=\"stylesheet\"/></HEAD><body><div class=\"wrap\"> "); //Justify.css is the name of the file in your assets folder
sb.append("YOUR TEXT");
sb.append("</div></body></HTML>");
web_view.loadDataWithBaseURL("file:///android_asset/", sb.toString(), "text/html", "utf-8", null);
Upvotes: 2