Reputation: 716
I have a Textview in which i need to show large information in proper format.How can i achieve it?
I want to display like this:
Title : Some Title.
Date : Date
More Info about the title.
......
......
Contact : Contact Details.
Upvotes: 0
Views: 816
Reputation: 20021
Well you have to do it by calculating the space between the options.
The better way
Use a Webview
make an html string with contents aligned properly using html formattings and load webview and display it.
Upvotes: 1
Reputation: 2821
As suggested by others, WebView is the option for you. See How to programmatically set / edit content of webview
However, it is possible to do it in a TextView if the text doesn't need special formatting (ex. different color, font sizes) and the only formatting required is indentation.
In layout:
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="false" />
In Activity:
TextView tv = (TextView) findViewById(R.id.text);
tv.setText("Title : Some Title.\nDate : Date\n\nMore Info about the title.\n......\n......\n\nContact : Contact Details.");
Upvotes: 0
Reputation: 53
I think there are three options.
Upvotes: 0
Reputation: 10313
If using a TextView is not essential you can use TableLayout:
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TableRow>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Title"
android:layout_weight="1"/>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Some Title"
android:layout_weight="2"/>
</TableRow>
<TableRow>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Date"
android:layout_weight="1"/>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="Some Date"
android:layout_weight="2"/>
</TableRow>
</TableLayout>
Upvotes: 0