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
2.some text
.............
</body>
</html>
]]>
</string>
I am setting scrollbarenabled to true to make vertical scrolling on my text.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…