答案 0 :(得分:1)
放在textView
的左侧,并使用所需的尺寸和颜色。
<View
android:layout_width="2dp"
android:layout_height="100dp"
android:background="@color/colorPrimaryDark"></View>
答案 1 :(得分:1)
使用
WebView webview = (WebView)this.findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadDataWithBaseURL("", data, "text/html", "UTF-8", "");
将webview用于Html文本
String a = "You can ";
String b = "change" ;
String c = "like this" ;
String d = "if want to make it bold";
String sourceString = a + " " + "<b>" + b + "</b>" + " " + c + " " + "<b>" + d + "</b>";
textView.setText(Html.fromHtml(sourceString));
这是您想要的代码
public Form1()
{
InitializeComponent();
List<KeyValuePair<string, bool>> UrlS = Link_Bul_v2("http://www.asdfhg.com", new List<string>(), new List<KeyValuePair<string, bool>>());
List<KeyValuePair<string, bool>> UrlS2 = Link_Bul_v2("http://www.huuene.com", new List<string>(), new List<KeyValuePair<string, bool>>());
}
string UrlSadelesti(string Link)
{
return Link.Replace("https://", "").Replace("http://", "").Replace("www.", "");
}
WebClient client = new WebClient();
private List<KeyValuePair<string, bool>> Link_Bul_v2(string Link, List<string> HList, List<KeyValuePair<string, bool>> CList)
{
try
{
string HtmlCode = client.DownloadString(Link);
//if(HtmlCode.
CList.Add(new KeyValuePair<string, bool>(Link, true));
var Link_Short = UrlSadelesti(Link).Split('/')[0];
//HList.Add(Link_Short);
string DLink;
int IndexH = 0;
while (true)
{
IndexH = HtmlCode.IndexOf("href", IndexH);
if (IndexH == -1) { break; }
if (HtmlCode[IndexH - 1] == '.')
{
IndexH = IndexH + 1;
}
else
{
var IndexD1 = HtmlCode.IndexOf('"', IndexH);
var IndexD2 = HtmlCode.IndexOf('"', IndexD1 + 1);
var length = IndexD2 - (IndexD1 + 1);
DLink = HtmlCode.Substring(IndexD1 + 1, length);
IndexH = IndexD2;
if ((DLink.Contains(".css") == false))
{
if (DLink.Contains("http://") || DLink.Contains("https://"))
{
if (DLink.Contains(Link_Short) == false)
continue;
}
if (DLink.Contains("#"))
{
continue;
}
DLink = UrlSadelesti(DLink).Replace(Link_Short, "");
if (DLink.Length == 1)
continue;
if (HList.Count(p => p.Contains(DLink)) == 0)
{
if (DLink.Contains("http://") || DLink.Contains("https://"))
{
HList.Add(Link_Short + "/" + DLink);
}
else
{
HList.Add("http://" + Link_Short + "/" + DLink);
}
}
}
}
}
}
catch
{
CList.Add(new KeyValuePair<string, bool>(Link, false));
if (!HList.Contains(Link))
HList.Add(Link);
if (UrlSadelesti(Link).Split('/').Count() > 1)
{
Link_Bul_v2("http://" + UrlSadelesti(Link).Split('/')[0], HList, CList);
}
}
foreach (string s in HList)
{
if (CList.Count(p => p.Key.Contains(s)) == 0)
{
Link_Bul_v2(s, HList, CList);
}
}
return CList;
}
它看起来像
你可以更改这样如果想要加粗
答案 2 :(得分:1)
您可以使用View
:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:orientation="horizontal">
<View
android:layout_gravity="right"
android:background="#000000"
android:layout_width="2dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_height="match_parent" />
<TextView
android:text="balblalblablalblablalblalb"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
看起来像:
要显示Html
,您可以执行以下操作:
yourTextView.setText(Html.fromHtml("your html string"));
答案 3 :(得分:0)
Step 1: Add a Linear layout in a layout.
<LinearLayout
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_margin="10dp">
</LinearLayout>
step2:In Activity , create TextView and a View dynamically add to linear layout
LinearLayout mylayout = (LinearLayout) findViewById(R.id.linear_layout);
TextView text = new TextView(this);
text.setText("Testing");
View view = new View(this);
view.setBackgroundColor(getResources().getColor(R.color.black));
view.setLayoutParams(new LinearLayout.LayoutParams(5, LinearLayout.LayoutParams.MATCH_PARENT));
mylayout.addView(view,0);
mylayout.addView(text,1);
希望它有所帮助!