![](/img/trans.png)
[英]In my android appciation i want to display textview like below image?
[英]I want to display the text in my TextView not as a paragraph but as a few points
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvQuestion1"
android:text=" Q1: What causes relapse?"
android:visibility="visible"
android:textStyle="bold"
android:fontFamily="sans-serif"
android:textColor="#00695C"
android:textSize="24sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tvAnswer1"
android:paddingLeft="12dp"
android:textSize="20sp"
android:maxLines = "15"
android:scrollbars = "vertical"
android:lineSpacingExtra="10dp"
android:textStyle="italic"
android:text="Various “triggers” can put people at risk of relapsing into old patterns of substance use.
Causes of relapse can differ for each person.
Some common ones include:
• negative emotional states (such as anger, sadness, trauma or stress)
• physical discomfort (such as withdrawal symptoms or physical pain)
• positive emotional states (wanting to feel even better)
• testing personal control (“I can have just one pill”)
• strong temptations or urges (cravings to use)
• conflict with others (such as an argument with a spouse or partner)
• social pressures to use (situations where it seems as though everyone else is using drugs)
• good times with others (such as having fun with friends or family)
"
android:visibility="gone"/>
嘿,要点,您可以使用:
textView1.setText("\u2022" + " " +YOUR TEXT);
\\ u2022会给您一个要点,然后使用\\ n断开该行。 祝你好运:D
试试这个代码:
XML中的字符串
enter code he<resources>
<string name="app_name">TestProject2</string>
<string name="html">
<![CDATA[
<h1>Main Title</h1>
<h2>A sub-title</h2>
<p>This is some html. Look, here\'s an <u>underline</u>.</p>
<p>Look, this is <em>emphasized.</em> And here\'s some <b>bold</b>.</p>
<p>This is a UL list:
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
<p>This is an OL list:
<ol>
<li>One</li>
<li>Two</li>
<li>Three</li>
</ol>
]]>
</string>
</resources>re
如果需要在点中显示数据,请在字符串中添加数据,这是一个简短的示例,它可以帮助您
xml布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:orientation="vertical"
android:gravity="top|fill_vertical">
<TextView
android:id="@+id/textView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<!--
<WebView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/webView"
android:layout_below="@+id/helloWorld"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
/>
-->
</LinearLayout>
MainActivity.java
package com.alvinalexander.testproject2;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.text.Html;
import android.text.Spanned;
import android.widget.TextView;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// get our html content
String htmlAsString = getString(R.string.html); // used by WebView
Spanned htmlAsSpanned = Html.fromHtml(htmlAsString); // used by TextView
// set the html content on a TextView
TextView textView = (TextView) findViewById(R.id.textView);
textView.setText(htmlAsSpanned);
// WebView webView = (WebView) findViewById(R.id.webView);
// webView.loadDataWithBaseURL(null, htmlAsString, "text/html", "utf-8", null);
}
}
这个例子看起来像:
请尝试一下,我认为它可以帮助您。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.