In my app first I have textview to show text. Then I want to justify text but in android its not possible to justify text in textview. To justify text I am taking help from this link. I am following the answer provided by @Kondzio but its not working. I dont know whats wrong in my code.
Code-
public class Benefits extends Activity{
private Button back;
LinearLayout bText;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.benefits);
WebView view = new WebView(this);
view.setVerticalScrollBarEnabled(true);
((LinearLayout)findViewById(R.id.bText)).addView(view);
view.loadData(getString(R.string.benef), "text/html", "utf-8");
back.setOnClickListener(new View.OnClickListener(){
public void onClick(View v)
{
finish();
}
});
}
}
Xml-
<LinearLayout
android:id="@+id/bText"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="4"
android:gravity="center">
</LinearLayout>
In strings.xml-
<string name="benef">
<![CDATA[
<html>
<head></head>
<body style="text-align:justify;color:gray;background-color:black;">
"1.some text\n
2.some text\n
.............
</body>
</html>
]]>
</string>
I am setting scrollbarenabled to true to make vertical scrolling on my text.
I modified code given by Sasikumar to correct followings.
This is pure text only solution. Html does not work. no linebreak (\n) or any other character works. All spaces are removed. So its just for limited , pure text use.