【发布时间】:2016-08-11 12:19:29
【问题描述】:
【问题讨论】:
-
您也可以使用 compound drawable(在本例中为
drawableLeft),并节省额外的视图。 -
你能解释更多吗?
-
请用谷歌搜索
android textview compound drawable
标签: android html textview blockquote
【问题讨论】:
drawableLeft),并节省额外的视图。
android textview compound drawable
标签: android html textview blockquote
放置在您的textView 左侧并使用您想要的尺寸和颜色。
<View
android:layout_width="2dp"
android:layout_height="100dp"
android:background="@color/colorPrimaryDark"></View>
【讨论】:
你可以使用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"));
【讨论】:
TextView,例如:TextView t = new TextView(context);,而不是设置LayoutParams
使用
<View android:id="@+id/view"
android:layout_height="match_parent"
android:layout_width="1dp"
android:background="#000000" />
对 HTML 文本使用 webview
WebView webview = (WebView)this.findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.loadDataWithBaseURL("", data, "text/html", "UTF-8", "");
这是你想要的代码
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));
看起来像
你可以像这样改变如果想加粗
【讨论】:
textview 并将文本设置为.setText(Html.fromHtml("Your html string"))
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);
希望对您有所帮助!
【讨论】: